What is the actual effect of the following construct:
class Base { /* ... */ };
template<class T>
class Derived : public T { /* ... */ };
int main() {
Derived<const Base> d;
// ...
}
Does the Derived
class only have access to the const
-part of the interface of Base
? My first tests indicate that there's actually no effect at all. Why?
Thanks!
My guess is that the const
is ignored, because if you try to write
class Derived : public const Base
the program doesn't compile.
EDIT:
frozenkoi gave the relevant part of the standard in the comments:
"A typedef-name (7.1.3) that names a class type, or a cv-qualified version thereof, is also a class-name. If a typedef-name that names a cv-qualified class type is used where a class-name is required, the cv-qualifiers are ignored. A typedef-name shall not be used as the identifier in a class-head." §9.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With