ardi
unread,May 19, 2013, 1:05:05 PM5/19/13You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
Hi again,
I've some classes with members that need to have a pointer to a GUI control.
However, the same member will have the same pointer in all instances of the class. I mean, member 'm_Temperature' from class 'CTown' will have the same value for its GUI control pointer in all instances of the class 'CTown'.
Thus, if I've 50000 objects of class CTown, I'm wasting a lot of unneeded pointers, since all of them have the same value.
My first idea is that I need another class, like for example CTownGUI, which stores the GUI pointers, so that CTown doesn't have to waste memory with them.
But, unfortunately, this makes the code harder to write: Everytime I add a new member in CTown, I've to add its counterpart to CTownGUI, and I need to code its GUI pointer management.
On the other hand, if I was OK with wasting memory, with the first approach I wouldn't need any extra coding when adding a new member to CTown: if the GUI pointer of the new member is managed on its base class, just add the new member to CTown, and everything works... well, works, but wasting a lot of pointers that have the same value.
So, do you have some clever idea which would allow all instances of a class to share the same memory location for a member?
Thanks!
ardi