Initializing a reference with constructor

Started by
0 comments, last by ApochPiQ 12 years, 11 months ago
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. ;-/
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.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

This topic is closed to new replies.

Advertisement