constructor array
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.
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:
Tadaa!
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!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement