PDA

View Full Version : vector



mickey
26th May 2006, 19:46
Hi, I've a public vector inside a class; I'd like code a function that return this vector;
like ah: obj.getVectorLight().begin(); I'd like make this vector private...

std::vector<Light> light;
std::vector<Light> getLight_vector();

How to write this function?

jacek
26th May 2006, 19:57
std::vector<Light> getLight_vector();
This method will return a copy of that vector --- you have to return a reference:

std::vector<Light>& getLight_vector() { return light; }