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.
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.