C
cppaddict
Hi,
Say I have a abstract base class and I know that every derived class
will have a static data member (call it SharedInformation)
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 SharedInformation as a static member of the base
class, then SharedInformation cannot vary across the different derived
classes, because all derived classes will pointing to the same static
instance of SharedInformation. 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
SharedInformation.
How can I solve this problem? That is, have my base say, "All derived
classes will have a static data member called SharedInformation" but
still be able to have different static instances of SharedInformation
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 SharedInformation)
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 SharedInformation as a static member of the base
class, then SharedInformation cannot vary across the different derived
classes, because all derived classes will pointing to the same static
instance of SharedInformation. 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
SharedInformation.
How can I solve this problem? That is, have my base say, "All derived
classes will have a static data member called SharedInformation" but
still be able to have different static instances of SharedInformation
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