[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
fundamental template inheritance problem.
From: |
Federico David Sacerdoti |
Subject: |
fundamental template inheritance problem. |
Date: |
Wed, 11 Jul 2001 11:48:37 -0700 |
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 class
template <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
- fundamental template inheritance problem.,
Federico David Sacerdoti <=