The following code will fail
class InComplte;
void f() {
new InComplte();
}
class InComplte {
};
Because it is newing an incomplete type. But if template is used, the following code can compile
template<typename T>
class CComCoClass {
public:
static void create_di(T**p) {
*p = new T();
}
};
class Book: public CComCoClass<Book> {
public:
int i = 3;
};
The base class CComCoClass
seems to be newing an incomplete type.
Why the Book can inherit a base class that creates it?