Common data of two objects

Hi all,
I am designing a program with C++. There are two objects in my program. The two objects perform quite different tasks, but they use one common large datum (One updates the datum and the other sends feed-back about the updates and so on...). Since the datum is quite large, transferring the data between those two is time-consuming. In this case, what should I design the objects?
Since I am not so familiar with OPP thinking, I would hope to have your helps. Thank you in advance.
Are you familiar with pointers ?..
Yes, I know pointers. But I made the data virtually belong to the two objects, like two people sharing a common bread. Using pointers I just think of making the data outside the two objects, and each has a pointer to it. Is it the way that you meant?
Yes. If you want it to look more like a member, use references instead. Another option would be to simply merge the two objects into one. It can be made to work, even if you need them separately at some cases, via (virtual) inheritance. I can't say whether that would be a logical design though.
Yeah, or perhaps you could create a "pretend" parent class that actually only contains one static member: the data.

Then have both of your classes inherit from that class. They'll inherit the static data and any changes made by one changes the other.
Yes, thank you very much.
I will think more about those ways tonight. Probably I choose the static parent class...
Topic archived. No new replies allowed.