I am relatively new to C++ OO:
How is this getter:
class A {
B b;
public:
B const &getB() const {
return b;
}
};
different from this one?
class A {
B b;
public:
const B &getB() const {
return b;
}
};
and this one?
class A {
B b;
public:
const B &getB() {
return b;
}
};
and which one is correct?
Edit This question has an answer here: Look for "consistent const" in http://isocpp.org/wiki/faq/const-correctness#overview-const