This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/3024: class inheritance of template arguments fail
- To: <jorgen dot sigvardsson at kau dot se>
- Subject: Re: c++/3024: class inheritance of template arguments fail
- From: "Artem Khodush" <artem at duma dot gov dot ru>
- Date: Fri, 1 Jun 2001 14:15:30 +0400
- >Received: from artem by mailsrv.duma.gov.ru (SMI-8.6/SMI-SVR4)id OAA22220; Fri, 1 Jun 2001 14:18:24 +0400
- Cc: <gcc-gnats at gcc dot gnu dot org>, <gcc-bugs at gcc dot gnu dot org>
- References: <20010601082825.27680.qmail@sourceware.cygnus.com>
> 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++.