Jump to content
  • Advertisement
Sign in to follow this  
andyb716

Dynamic array question.

This topic is 5409 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'm trying to make a dynamic array of my Tile Class for my 2D game. The thing is I dont know how to make it dynamic based on how many tiles I want for a board. So heres what I have in my application class. cTile m_Tile[TILECOUNT]; And that has a set number of tiles but how would I just make a blank array and then fill it according to how many tiles I want? I was thinking about this. cTile m_Tile = new cTile(); But thats just for one tile right? I need to learn how to make array or something. Should I use an array or vector? Which one be easy to use and effecient? thanks for any comments.

Share this post


Link to post
Share on other sites
Advertisement
In C++, "dynamic array" is spelled "vector". They are easy to use and efficient.


std::vector<cTile> m_Tile;
m_Tile.resize(TILECOUNT);

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!