T
Tony Johansson
Hello Experts!
I reading a book called programming with design pattern revealed
by Tomasz Muldner and here I read something that I don't understand
completely.
Im I right if I say the following.
In this case is the derived class a class template and the base class a
class template.
Both the base class and the derived class will be instansiated with some
specific type T
template <typename T>
class MyStack : public Stack<T> {. . .}
You cannot derive a concreate class from a class template as in
class IntStack : public Stack<T,100> {. . .} why.
Is it because the base class will not be instantiated with a type.
I mean if the base class could be instansiated with a type then this kind of
inheritance should be valid.
What does this text try to say..
"Instantiations of template are unrelated, even if classes for these
instantiations
are in a inheritance relation(that is, one is derived from the other). For
example,
given a general BankAccount class that has a derived class CheckingAccount,
there is no inheritance relation between Stack<BankAccount> and
Stack<CheckingAccount>".
Many thanks
//Tony
I reading a book called programming with design pattern revealed
by Tomasz Muldner and here I read something that I don't understand
completely.
Im I right if I say the following.
In this case is the derived class a class template and the base class a
class template.
Both the base class and the derived class will be instansiated with some
specific type T
template <typename T>
class MyStack : public Stack<T> {. . .}
You cannot derive a concreate class from a class template as in
class IntStack : public Stack<T,100> {. . .} why.
Is it because the base class will not be instantiated with a type.
I mean if the base class could be instansiated with a type then this kind of
inheritance should be valid.
What does this text try to say..
"Instantiations of template are unrelated, even if classes for these
instantiations
are in a inheritance relation(that is, one is derived from the other). For
example,
given a general BankAccount class that has a derived class CheckingAccount,
there is no inheritance relation between Stack<BankAccount> and
Stack<CheckingAccount>".
Many thanks
//Tony