Problem with Class Template!

hi everybody!
i don't know what's wrong with this class template declaration!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <iostream>
#include <conio.h>
using namespace std;
template<class T>
class X{
	private:
		T a;
		T b;
	public:
		X(T,T);
		void change_a(T);
		void change_b(T);
		T _return_a();
		T _return_b();
};
template<class T>
X<T>::X(T x,T y){
	this->a=x;
	this->b=y;
}
template<class T>
void X<T>::change_a(T x){
	this->a=x;
}
template<class T>
void X<T>::change_b(T y){
	this->b=y;
}
template<class T>
T X<T>::_return_a(){
	return this->a;
}
template<class T>
T X<T>::_return_b(){
	return this->b;
}
template<class T>
int main(){
X<int> test(10,4);
cout<<test._return_a;
_getch();
return 0;
}

when i compile it in Visual Studio, the following error appears!
Error 1 fatal error LNK1561: entry point must be defined

i've also compiled it in devC++,with no result (actually the errors in Dev were "38 cannot declare `::main' to be a template"
and
40 confused by earlier errors, bailing out )

so please help me!
i'll be thankful!

1
2
3
4
5
6
7
template<class T> // illegal - this is what the "cannot declare `::main' to be a template"" error means
int main(){
X<int> test(10,4);
cout<<test._return_a; // _return_a is a function - _return_a()
_getch();
return 0;
}
Last edited on
thank u very much!
i really appreciate you!
Topic archived. No new replies allowed.