Jump to content
  • Advertisement

Archived

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

vbisme

Object on free store

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

How do you create an array of a class on a free store with defined constructor? [source] MYCLASS * someClass; //normally someClass = new MYCLASS[5]; //but with constructor someClass = new MYCLASS(param, param)[5]; [/soure] doesn''t work, how could it be done?

Share this post


Link to post
Share on other sites
Advertisement
    

MYCLASS** someClass;
someClass = new MYCLASS*[5];
for(int i=0;i<5;i++)
someClass<i>= new MYCLASS(param, param);

for(int i=0;i<5;i++)
delete someClass[i];
delete[] someClass;

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!