Access of nested classes (which behave like friends, but aren't)
问题 Without long delay, here the code which I have no clue why it does what it does: #include <iostream> class A { private: void print() { std::cout << "A.print() called" << std::endl; }; public: template<typename Foo> class B; //NOTE: no friend! public: A(); B<double>* bd; B<int>* bi; }; template<typename Foo> class A::B{ A* callback; public: B(A* a):callback(a){}; void print() { callback->print(); }; // Why is this working ??? }; A::A():bd(new B<double>(this)),bi(new B<int>(this)){} int main