Consider the following code:
class A{
my_method(const B& b){
import_something_from_c(this, b.getC()); // does some sort of copying
}
}
class B{
const C& getC() const { return c; };
}
function f(B b){
b.getC().changeSomething();
}
Since my_method guarantees const, b.getC() must also be const. In f however, I do not guarantee constness and I do want to change the very same b.getC().
Is there some sort of a way to propagate the constness of an object to methods returning references to its members?