It seems like that returning reference is not a good practice (Is the practice of returning a C++ reference variable, evil?).
For this example, which would be better: return reference or return value?
class A
{
B b;
public:
B getB() {return b;} // ??? return value
B& getB() {return b;} // ??? return reference;
};
I guess it's OK to return reference as the returned value is still in memory, but I'm not sure what normally C++ programmers do. Are there any guidelines on when to return value vs when to return reference (or pointer)?