This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: c++/3024: class inheritance of template arguments fail


> 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++.




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]