Common variables between objects
Posted on 2001-06-19
I have a number of objects that are of different classes(derived from the same base class), but certain variables from the different objects are supposed to be common. For example...
class bob: public person
class tom: public person
I need it so if I set bob.parents = 2 then tom.parents also = 2.
Would the best way to do this is set bob and tom as friends, and everytime the parents value changes for one, manually change it for the other? Or is there a way to link these two members so they will alway be the same value?