Jump to content
  • Advertisement

Archived

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

Beowulf_

map<int, *CSURFACE> ????

This topic is 5710 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 want to do this: map Maps; ...but the compiler screams at me when I try. It will, however, let me do it without the ''*''. I want to be able to do this: int mapID; CSURFACE mSurface = new CSURFACE(filename, mapID); // mapID is passed by reference, filled with ''1000'' for example. Maps[mapID] = *mSurface; ... and then later, do this: Maps[1000]->SetChar(...etc.) How do I do this? I''m guessing it''s somehow POSSIBLE to do a map with a pointer as it''s value...

Share this post


Link to post
Share on other sites
Advertisement
Basic C++ syntax error : a pointer is TYPE* not *TYPE. Thus map<int, CSURFACE*> Maps;.

And keep in mind that you will have to manually walk through the map and delete the pointers before destroying the map... otherwise you will have memory leaks.

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]

Share this post


Link to post
Share on other sites
Holy guacamole, that explains alot! That makes perfect sense though, because you say:

CSURFACE *pSurface;

not:

*CSURFACE pSurface;

... seems so obvious now. Thanks!

I''m aware of memory leak issues. Thanks for the tip, though.

Share this post


Link to post
Share on other sites

  • 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!