• Advertisement
Sign in to follow this  

Initializing a reference with constructor

This topic is 2463 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
Sign in to follow this  

  • Advertisement