# 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.

## 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?

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 on other sites
Aside from the missing : after your "public", that code should be fine.

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