Start New Discussion within our Software Development Community

Guys I'm having a problem which is really annoying me ..
I'm trying to change a normal class into a template class, but every time I try to do that I get a bunch of problems with the object of that class and the template :
let's say I have this program ( this program is working properly )

//HD.h - header
class Test {
public:
   Test();                // constructor
   void MTD();      // input sales from keyboard
private:
   double X;
   double y;
};
//IMPLE.cpp - implementation 
#include <iostream>
#include "HD.h"
using namespace std;
Test::Test()
{ X=0; }
void Test::MTD()
{
	y=0;
	cout<<"reached"<<endl;
}
//MII.cpp - main
#include <iostream>
#include "HD.h"
using namespace std;
void main()
{
	Test c;
	c.MTD();
}

now the problem starts here I will try to change it into a template class :

//HD.h - header
const int Dsize=10;
template <class T>
class Test {
public:
   Test(int itsSize=Dsize);                // constructor
   ~Test(){delete[]pType;}  
   void MTD();    
   Test& operator=(const Test&);
   T& operator[](int offSet){return pType[offSet];}
private:
	T* pType;
	int itsSize;
   double X;
   T y;
};
//IMPLE.cpp - implementation 
#include <iostream>
#include "HD.h"
using namespace std;
template <class T>
Test<T>::Test(int size):itsSize=size
{	X=0;
pType=new T [size];
}
template <class T>
void Test<T>::MTD()
{
	y=0;
	cout<<"reached"<<endl;
}
//MII.cpp - main
#include <iostream>
#include "HD.h"
using namespace std;
void main()
{
	Test<T>c(1);
	c.MTD();
}

please help me my friends
it says
1.'T' : undeclared identifier
2.'Test' : class has no constructors
3.'Test<T>::MTD' : cannot convert 'this' pointer from 'Test' to 'Test<T> &'

ok the problem was with declaring the object , it is supposed to be
int , double , float etc .......
not this

Test<T>c(1);

this

Test<Typename(int float)>c(1);
This question has already been answered. Start a new discussion instead.