Hey, there, I have this class written several months ago when I had a reference book at hand, and pretty much imitated it. Now I cannot figure out the definition of getdata() anymore, and cannot find the reference neither. Please explain to me how to define getdata() such that it won't modify data itself, and it returns a const reference to the data, such that caller will not change data as well. Does the current definition meet the requirement? Thanks!
Code:
class Log{
private:
string name;
vector<TimePrice> data;
...
public:
vector<TimePrice> const& getdata(){
return data;
}
}