'C++ Member Functions (getters)

I've seen people define a member function like this:

void getValue(int& v)
{
    v = m_value;
}

and also like this:

int getValue()
{
    return m_value;
}

I guess the first saves memory? Is that the only time you would use the first type of get-function? The second seems a lot more convenient.

c++


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source