Jump to content
  • Advertisement
Sign in to follow this  
Jarwulf

constructor array

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

So I currently have this as an object declaration in a C++ file. obj bullet(0.f,0.f,0.f,0.f); I was wondering if I could do this obj bullet[3](0.f,0.f,0.f,0.f); and save myself the trouble of putting down three constructors.

Share this post


Link to post
Share on other sites
Advertisement
Unfortunately that's not possible (otherwise you wouldn't have asked in the first place).

But, if you used an std::vector, instead of a plain old array, you could to it like this:

std::vector<obj> bullet(3, obj(0.f,0.f,0.f,0.f));


Tadaa!

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.

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!