V
Vinesh S
Hello all,
I wanted to use inheritance in the typename.
for. eg.
template <class T>
class Listener
{
.....
T* ptr;
};
and in the main ...
Listener<BaseAdapter>* listenerPtr1 = new
Listener<ChildAdapter>(<param>);
where BaseAdapter -> ParentClass
ChildAdapter-> Child class derived from BaseAdapter.
==================================================
when i tried to compile, it throws an error
saying
error: cannot convert ‘Listener<ChildAdapter>*’ to
‘Listener<BaseAdapter>*’ in initialization
How can i get around this problem?
As i want a class template whose typename is a base class and the
instances use the child class....
is this possible ?
Waiting to hear from you guys,
Thanks,
Vinesh.S
When i try this in my program, it throws a compilation error.
I wanted to use inheritance in the typename.
for. eg.
template <class T>
class Listener
{
.....
T* ptr;
};
and in the main ...
Listener<BaseAdapter>* listenerPtr1 = new
Listener<ChildAdapter>(<param>);
where BaseAdapter -> ParentClass
ChildAdapter-> Child class derived from BaseAdapter.
==================================================
when i tried to compile, it throws an error
saying
error: cannot convert ‘Listener<ChildAdapter>*’ to
‘Listener<BaseAdapter>*’ in initialization
How can i get around this problem?
As i want a class template whose typename is a base class and the
instances use the child class....
is this possible ?
Waiting to hear from you guys,
Thanks,
Vinesh.S
When i try this in my program, it throws a compilation error.