Jump to content
  • Advertisement
Sign in to follow this  
SuperVGA

Initializing a reference with constructor

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

Hey guys!

I've run into a little problem to which i'd like some help:

I have a vector of struct rgba, which just contains POD (4 unsigned bytes).
A class of mine has a reference to this, which must obviously be initialized in an initializer list:


class image
{
private: std::vector< rgba > & img_data;
public image(std::vector< rgba > & _data) : img_data(_data) {}
};


But I'm not allowed to do that, and I just left my compiler and i cannot remember the error. :-S
How can i use my reference (i love references) while initializing it properly on the creation of image?

I read something about overloading assignment or copy operators,
but is that possible when T is a struct, and how do i do that?

Thanks a bunch in advance, I've been sleepless for two days because of this. ;-/

Share this post


Link to post
Share on other sites
Advertisement
Aside from the missing : after your "public", that code should be fine.

Please post the actual code you are using with the actual error.

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!