Hi,
Say I have a abstract base class and I know that every derived class
will have a static data member (call it SharedInformati on)
representing information to be shared across all instances of that
derived class. However, this information will be differenet for each
derived class.
Now, if I define SharedInformati on as a static member of the base
class, then SharedInformati on cannot vary across the different derived
classes, because all derived classes will pointing to the same static
instance of SharedInformati on. However, if I don't define it in the
base class, then someone looking at the base class won't know that
every derived class must define a static data member
SharedInformati on.
How can I solve this problem? That is, have my base say, "All derived
classes will have a static data member called SharedInformati on" but
still be able to have different static instances of SharedInformati on
for each base class.
I know I may be looking at this problem in the wrong light. If so,
I'd appreciate any suggestions on how to re-conceptualize it.
thanks,
cpp
Say I have a abstract base class and I know that every derived class
will have a static data member (call it SharedInformati on)
representing information to be shared across all instances of that
derived class. However, this information will be differenet for each
derived class.
Now, if I define SharedInformati on as a static member of the base
class, then SharedInformati on cannot vary across the different derived
classes, because all derived classes will pointing to the same static
instance of SharedInformati on. However, if I don't define it in the
base class, then someone looking at the base class won't know that
every derived class must define a static data member
SharedInformati on.
How can I solve this problem? That is, have my base say, "All derived
classes will have a static data member called SharedInformati on" but
still be able to have different static instances of SharedInformati on
for each base class.
I know I may be looking at this problem in the wrong light. If so,
I'd appreciate any suggestions on how to re-conceptualize it.
thanks,
cpp
Comment