I have these 3 classes.
class A
{
public:
virtual void Func() = 0;
};
template<class T>
class B : public A
{
public:
void Func()
{
cout << "In B" << endl;
static_cast<T*>(this)->Func();
}
};
class C : public B<C>
{
public:
void Func()
{
cout << "In C" << endl;
}
};
And, I do this:
int main(int argc, char **argv)
{
A *a = new C;
a->Func();
return 0;
}
And it prints : "In C".
If I do this,
int main(int argc, char **argv)
{
B<C> *a = new C;
a->Func();
return 0;
}
It again prints "In C"
What is going on?