I am writing a class with a link to const as follows:
class B;
class foo {
const B& b;
foo(const B& newb): b(newb) { }
void operator=(const foo & foo2) {
foo.b = foo2.b;
}
};
I am trying to define a working operator = Obviously = does not work, since I am not allowed to change the reference to the constant. Is this a way to give a link to another object?
If b is not const, C ++ will provide me with a working = operator. If I define one member as const cl, it will spit out:
warning C4512: 'foo': assignment statement cannot be generated
source
share