defining arrays in initializer lists
If I declare in my header file something like
Vec3 myVector;
How can I define it in the initializer list?
If I declare and define it in the constructor using
Vec3 myVector = {1,2,3}
Does it have class scope ?
Regards
It won't have class scope if you define it in the constructor like that. As for the other question, I don't think you'll be able to do it... you'll have to assign each member of myVector manually (unless I'm understanding your question wrong which is also likely :) ).
You've missed out important parts, such as the definition of Vec3. However since you are using curly brackets, that suggests that Vec3 is simply an array.
In that case, you can't use an initialiser list, but if you wrap it up in a class instead, with a three-argument constructor, then you can do as you request.
In that case, you can't use an initialiser list, but if you wrap it up in a class instead, with a three-argument constructor, then you can do as you request.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement