This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Bug in EGCS 1.1b (better than 1.0.3a though)


Christopher Curtis <ccurtis@ee.fit.edu> writes:

> On 18 Sep 1998, Alexandre Oliva wrote:

>> /home/msc/oliva/test.cc:6: ANSI C++ forbids in-class initialization of
>> non-const static member `References'

> But if it is the spec, I don't get it.  How can I ever have a sane
> starting value for 'References'?

Every static data member must be defined outside the class body,
*even* if it is initialized within the class body.  So, in your
example, we'd have:

template<class T> class MoreComplex : public complex<T> {
private: static int References; };
template <class T> int MoreComplex<T>::References = 0;

-- 
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]