I read following code from somewhere:
template<class T> class A {
T a;
public:
A(T x):a(x) {}
operator T() const {return a;} // what is point here?
};
int _tmain(int argc, _TCHAR* argv[])
{
A<int> a = A<int>(5);
int n = a;
cout << n;
return 0;
}
What does below line mean?
operator T() const {return a;}
This is the typecast operator. It’ll implicitly convert the class instance to
T. In the example code you’ve posted this conversion is being performed at the line