Path: utzoo!attcan!utgpu!utstat!jarvis.csri.toronto.edu!rutgers!att!ulysses!andante!alice!ark From: ark@alice.UUCP (Andrew Koenig) Newsgroups: comp.lang.c++ Subject: Re: static members Message-ID: <9389@alice.UUCP> Date: 24 May 89 14:42:09 GMT References: <360@msor0.UUCP> Organization: AT&T Bell Laboratories, Liberty Corner NJ Lines: 35 In article <360@msor0.UUCP>, kt@msor.UUCP (Keith Tizzard) writes: > "No initializer can be specified for a static member, and it cannot > be of a class with a constructor." > 1 the meaning of the piece after the comma is not clear to me - > does it really mean that if I provide a constructor for a class > then I cannot have a static member variable in that class? No. It means that if T is a class with a constructor, no static members of a class may be of type T. Example: class T { public: T(); }; class S { public: static T t; // illegal }; This will change in C++ 2.0; the example above will be legal but S::t will have to be defined explicitly somewhere in the program: T S::t; The reason for requiring a separate definition is that the declaration of class S may be compiled several times in separate source files; requiring a single definition is the only way to cope with the various linkers out there. -- --Andrew Koenig ark@europa.att.com