Bil*_* Li 8 c++ operator-overloading
我从某处读了以下代码:
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;
}
Run Code Online (Sandbox Code Playgroud)
下线是什么意思?
运算符T()const {return a;}