Hi,
I am writing class with a const reference like this:
class B;
class foo {
const B& b;
foo(const B& newb): b(newb) { }
void operator=(const foo & foo2) {
// This does not work
foo.b = foo2.b;
}
};
I am trying to define a working operator= Obviously = does not work since I am not allowd to change a const reference. This there a way to let a reference point to another object?
If b is not const c++ will provide me with a working operator=. If I define one member as const cl will spit out:
warning C4512: 'foo' : assignment operator could not be generated