Message-ID: <359D624A.3C0599DA@uol.com.br> Date: Fri, 03 Jul 1998 19:59:22 -0300 From: "Juciê Dias Andrade" MIME-Version: 1.0 To: A White CC: djgpp AT delorie DOT com Subject: Re: g++: inheriting static members References: <359CFE52 DOT 2A0B AT sympatico DOT ca> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Precedence: bulk There is another way to achieve the same efect. You can declare a virtual funtion in the basic class, thus "overriding" what would otherwise be a static data member. The trick: class Base { public: virtual const char *className() const { return "Base"; } }; class Derived : public Base { public: virtual const char *className() const { return "Derived"; } }; class AnotherDerived : public Base { public: virtual const char *className() const { return "AnotherDerived"; } }; #include void showClassName(const Base *object) { puts(object->className()); } int main() { showClassName(new Base); showClassName(new Derived); showClassName(new AnotherDerived); return 0; } Did you understand? []s Obs.: Excuse my poor English, that's not my native language (need I a compiler?). A White escreveu: > I'm playing with a small bit of code and wanted to do the following: > > class obj { > public: > static const char Name[]; > }; > > class newbie: public obj > { > ... > }; > > class doobie: public obj > { > ... > }; > > I'd want to initialize the obj::Name to "SimpleObj", and the other two to > "newbie" and "doobie" respecitvely.