有价值题目
#include <iostream> using namespace std; class A{}; class B { public: operator A()//重载操作符,这个是操作符,从B 类型 转为A类型,
{ return A(); } }; void func(A){ cout<<"this is from func"<<endl; } void main() { B b; func(b); }
class B{ double a; public: operator double(){ return a; } } int main(){ B b; double c = double(b); }