Facing problem in creating object of derived class (whish is derived from template class) and pushing object in list

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi,

My base class is template class as:

template<typename T>
class CheckTemp
{
T a;

public:
CheckTemp(){}
void display(T a);
};

Derived class as:

class TestDerive: CheckTemp<int>
{
int a;
public:
void Print();
};

I have to make container of TestDerive objects. Declared list as:
typedef std::list<CheckTemp<int>* > ptls;

Code in main() where error occurs is as below:

int main()
{
ptls pls;
CheckTemp<int> obj = new TestDerive();
pls.push_back(obj); //Error in this line
return 0;
}

Errors are:
Error 2 error C2664: 'std::list<_Ty>::push_back' : cannot convert parameter
1 from 'CheckTemp<T>' to 'CheckTemp<T> &'
d:\mqsamples\templatesample\testmain.cpp 35


Error 1 error C2440: 'initializing' : cannot convert from 'TestDerive *' to
'CheckTemp<T>' d:\mqsamples\templatesample\testmain.cpp 34

Also I want to know Is derived class is also a Template class?

What could be the reason for this problem?

Any pointers or help to resolve this problem is appreciable.

Thanks And Regards
Shilpa


.



Relevant Pages

  • gcc 3.4 template compilation problem
    ... I had what I thought was proper SFINAE code. ... template class that I only want to be usable when the class is ... int a; ... void f ...
    (comp.lang.cpp)
  • Re: Inheritance with pointers:Overloading?
    ... >> my one base class is a linklist class. ... >> The problem is that when i use the derived class i can't ... void LLClass::setnext ... void Point::setvalues(int xx, int yy) ...
    (comp.lang.cpp)
  • Help in Java swings(internal Frame)
    ... public int getSize() ... public void valueChanged{ ... private JScrollPane scrollPane1; ... public class PeakContainer extends JInternalFrame ...
    (comp.lang.java.programmer)
  • [PATCH] get rid if __cpuinit and __cpuexit
    ... unsigned long action, void *hcpu) ... unsigned int cpu = hcpu; ... -static int __cpuinit ... __cpu_up(unsigned int cpu) ...
    (Linux-Kernel)
  • [PATCH,RFC 2.6.14 09/15] KGDB: SuperH-specific changes
    ... This adds basic support for KGDB on SuperH as well as adding some architecture ... -static int kgdb_uart_getchar ... -static void kgdb_uart_putchar ... * The command-line option can include a serial port specification ...
    (Linux-Kernel)