Sign in to follow this  
Jarwulf

constructor array

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this