Advertisement Jump to content
Sign in to follow this  
moetman

defining arrays in initializer lists

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

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

Share this post


Link to post
Share on other sites
Advertisement
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 :) ).

Share this post


Link to post
Share on other sites
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.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!