Jump to content
  • Advertisement
Sign in to follow this  
homojedi

Should i 'new' or not

This topic is 3181 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 originally post this in begginer but its a little more gamer specific so I thought id ask to collective knowledge that frequent's this forum as well just a quick question on pass by reference and value and vectors. i have 3 class's class EntityManager( Singleton ) { vector<Entity_information> entityVec; }; class Entity_information { vector<Animation_info> animationInfo; }; class Animation_Info { vector<SDL_Rect> Frames; }; now i know when dealing with vectors of classes that have vectors. its usually a good idea to send a pointer which has had memory allocated to make sure your dealing with the original address at all times. SO my question is with my code should i change all the stored vector values to new'd pointers? or because that the class thats managing them all is a singleton( EntityManager ) that it doesent matter? The only reason i havent new'd them yet is i dont want to be allocating memory if i dont need too. The reason i ask this is that my Entity_information class will hold the sprite position on screen and that value will have to be used and changed as its passed around instead of a copy..so i suppose i could just always pass those 2 values X,Y around as references...any thoughts?

Share this post


Link to post
Share on other sites
Advertisement

This topic is 3181 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.

Guest
This topic is now closed to further replies.
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!