c++/3024: class inheritance of template arguments fail
Artem Khodush
artem@duma.gov.ru
Fri Jun 1 03:21:00 GMT 2001
> Classes may not inherit from template argument. I use this with
> the Microsoft Visual C++ compiler frequently (ATL uses it heavily).
> I don't know if this is C++ by the book, or if it is a Microsoft extension.
>
> The code which fail for me looks like:
>
> template <typename T>
> class Y : public T
> {
> // ...
> };
>
> class X : public Y<X>
> {
> };
>
Your code does not compile with Visual C++ 6.0.
The error message is pretty much the same:
c:\m\t\main.cpp(4) : error C2504: 'X' : base class undefined
This has nothing to do with inheriting from template argument.
You want to have a class which indirectly inherits from itself,
this is impossible in C++.
More information about the Gcc-bugs
mailing list