Jump to content
  • Advertisement
Sign in to follow this  
easyBob0101

Data betwee objects

This topic is 3886 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

I did a search, but I don't think I used the right keywords for what I need, so I'll explain. I have a class that gets used a lot. In this class is a lookup table(loaded from a file) that can be very very big. Now, I don't want that lookup table to load every time I create an object of that class. So, how do I load that table once and have all the instances be able to access it? Oh, and if there is a solution, does it have a name? I just don't want to fill up memory with useless data. Thanks, -Chris

Share this post


Link to post
Share on other sites
Advertisement
SiCrane, I'm using C++/CLI, or whatever...managed C++ is what I call it. :shrug:

TheUnbeliever, I thought about that, but I just don't think that is best.

ClassA a1 ("slkdfj", table);
ClassA a2 ("gfagf", table);
ClassA a3 ("ggwv", table);
ClassA a4 ("slvbekdfj", table);

That just looks so inefficient.

Logically, this class, and only this class need the lookup table, just not multiple copies of it in memory.

What I would like to see is the table loaded on the first instance of the class, and the rest just use that....

-Chris

Share this post


Link to post
Share on other sites
Quote:
Original post by jeff75225
In C++ you would declare the table as static....I think that is the word you were looking for


Yes! I do believe that is it! Thank you all!

"When modifying a data member in a class declaration, the static keyword specifies that one copy of the member is shared by all instances of the class."

-Chris

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!