|
From: | Federico David Sacerdoti |
Subject: | Re: fundamental template inheritance problem. |
Date: | Thu, 12 Jul 2001 17:06:23 -0700 |
Right, that was a typo on my part. It doesn't change my main point, however. There still is no reason for g++ to force us to name the template type of our *base* class, since it must be the same as the *derived* class.
Dave
Artak Avetyan wrote:
Hi
right code is (pay attention on "^^^^^"):template <class T>
class A
{
};template <class T>
class B : public A<T>
^^^^^^^^^
{
};Regards,
Artak.
Federico David Sacerdoti wrote:
g++ (2.95.2, others)
Problem: a derived templated class inherits a templated base class.template <class T>
class A {};
template <class T>
class B : public class A {};
In class B's constructor C++ requires that we explicitly name the type of our
base classtemplate <class T>
B<T>::B () :
A<T>()
{
}This only makes sense if class B's type can be different than class A's. But
since B 'is an' A having different template types is not possible. Therefore
there is NO REASON for us to call A<T>, the compiler should know this
implicitly. This is a deficiency of the language, a mis-definition of
'template' which says a derived class may have a different type than its base.
I suggest we fix it, in the compiler.Everyone I know who has tried this has made the same mistake. Mis-definitions
such as this make templates harder to use, and cause object-oriented
programmers to turn to other languages.Federico David Sacerdoti
_______________________________________________
Bug-gplusplus mailing list
address@hidden
http://mail.gnu.org/mailman/listinfo/bug-gplusplus
[Prev in Thread] | Current Thread | [Next in Thread] |