J
Jarma
Taking such a piece of code:
template<class T>
class Data
{
public:
Data(T v) : value(v) {}
T GetValue1() const { return value; }
const T & GetValue2() const { return value; }
private:
T value;
}
GetValue1() and GetValue2() are both accessors to value. Which usage is
better? GetValue1() type seems to me to be more common although I think that
GetValue2() is more effective especially when value is a big class. Am I
right?
template<class T>
class Data
{
public:
Data(T v) : value(v) {}
T GetValue1() const { return value; }
const T & GetValue2() const { return value; }
private:
T value;
}
GetValue1() and GetValue2() are both accessors to value. Which usage is
better? GetValue1() type seems to me to be more common although I think that
GetValue2() is more effective especially when value is a big class. Am I
right?