Sign in to follow this  
SuperVGA

Initializing a reference with constructor

Recommended Posts

SuperVGA    1132
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:

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this