有价值题目

#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);
}

 

posted @ 2013-05-14 22:03  herizai  阅读(111)  评论(0编辑  收藏  举报