www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/07/03/09:00:33

Message-ID: <359CFE52.2A0B@sympatico.ca>
From: A White <awhite AT sympatico DOT ca>
Organization: Brinks SFB Solutions Ltd
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: g++: inheriting static members
Lines: 30
Date: Fri, 03 Jul 1998 12:54:03 GMT
NNTP-Posting-Host: 206.172.192.59
NNTP-Posting-Date: Fri, 03 Jul 1998 08:54:03 EDT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Greetings from Toronto, ON

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.

The compiler gives an error about redefing obj::Name and I can understand
that.  IS there an alternative?  I don't want to have to define a static
class member for every class the inheriets(?) from 'obj' - at some point
I'll forget, or the class structure gets bloated (okay, inheriting will
cause bloating, but it will be invisible to me eyes).

Thanks.
A White

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019