Jump to content
  • Advertisement

Archived

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

HappyToLearnC

The "new" versus regular datatype

This topic is 5985 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 Forum Could some one give me just a hint of when I should create a class object with the new operator and when I should create it as a regular data type.(You may not need explain the heap and the stack, and the need to delete the object created with new) Many thanks

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
when in doubt put it on the stack

Share this post


Link to post
Share on other sites
the ONLY reason to use new is for dynamic allocation. if you know exactly how many things you will ever need, then you can stick with static arrays. but if you use static arrays, you cant control their life time beyond their scope. if you use new, the memory is not tied to any specific function, and you can delete them when you want.

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!