Name: Anonymous 2007-02-25 2:58 ID:ZVnyBiRu
Wrap your head around this one:
Can anyone explain to me how the compiler manages to get this right? (and it does, somehow) Keep in mind the following: Save for access restrictions, the class B<A> knows about any and all of A's constructors and static member functions. At the same time, class A knows about any and all members of B<A>.
Doesn't the compiler have to compile the base class before compiling the derived? That means compiling B<A> before A, but with the way templates work you have to compile A before B<A>.
template <typename T> class B { /*...*/ }
class A : public B<A> { /*...*/ }Can anyone explain to me how the compiler manages to get this right? (and it does, somehow) Keep in mind the following: Save for access restrictions, the class B<A> knows about any and all of A's constructors and static member functions. At the same time, class A knows about any and all members of B<A>.
Doesn't the compiler have to compile the base class before compiling the derived? That means compiling B<A> before A, but with the way templates work you have to compile A before B<A>.