#include <iostream>
#include <conio.h>
usingnamespace 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(){
returnthis->a;
}
template<class T>
T X<T>::_return_b(){
returnthis->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 )
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;
}