Default assignment operator in inner class with reference members
I've run into an issue I don't understand and I was hoping someone here might provide some insight. The simplified code is as follows (original code was a custom queue/queue-iterator implementation): class B { public: B() {}; class C { public: int get(); C(B&b) : b(b){}; private: B& b; }; public: C get_c() { return C(*this); } }; int main() { B b; B::C c = b.get_c(); c = b.get_c(); return EXIT_SUCCESS; } This, when compiled, gives me the following error: foo.cpp: In member function 'B::C& B::C::operator=(const B::C&)': foo.cpp:46: error: non-static reference member 'B& B::C::b', can't use