A
Allerdyce.John
Hi,
I have a class with a STL vector as it attribute.
How can I create a method which just return a 'read-only' view? (i.e.
the caller of the function can only read the vector, not write it)?
class A {
private:
vector<int> _v;
public:
vector<int>& getV() { return _v;} // how to make sure the caller can
only read the content of the array?
}
Thank you.
I have a class with a STL vector as it attribute.
How can I create a method which just return a 'read-only' view? (i.e.
the caller of the function can only read the vector, not write it)?
class A {
private:
vector<int> _v;
public:
vector<int>& getV() { return _v;} // how to make sure the caller can
only read the content of the array?
}
Thank you.