Archived

This topic is now archived and is closed to further replies.

Problem - Class member data being overwritten

This topic is 6019 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I have a problem with one of my classes. For convinience, all class member data is PUBLIC at the moment, which may effect it, but I still can''t see why this is happening. I have a certain class which just holds a few ints and floats and stuff. I have another, similar class. To access them I have declared an array of pointers (the pointers for each class are kept in seperate arrays), and I am creating pointers to objects of each class when I create the objects: PointerArray[ObjectNumber] = new Object; I have a line in my code which, like other similar lines around it, sets up some class member data: PointerArray[Object]->MemberData = SomeInteger; However, it appears to be overwriting member data of another class as well! For instance: PointerArrayForClass1[Object]->MemberData = SomeInteger; Not only is this setting Class1.MemberData to SomeInteger, it is (somehow) also setting Class2.OtherMemberData to SomeInteger. I have NO idea why this happens, can anyone shed some light? Thanks Rottbott

Share this post


Link to post
Share on other sites
Do you have some code samples to show?

Do you declare your lists as static lists? Are you initialize the second list with a pointer from the first list?

Share this post


Link to post
Share on other sites
I am declaring them as static, although outside any functions so that could be it...

As for showing code, I''d love to, but it''s part of a large project and is scattered everywhere.

So shall I try sticking the declarations in an Init() function?


Rottbott

Share this post


Link to post
Share on other sites