#include "stdafx.h"
#include <iostream>
class Ch
{
private:
int t;
public:
operator int() const;
Ch(int m);
// friend int operator+(int t,const Ch & o);
};
Ch::Ch(int m)
{
t = m;
}
Ch::operator int() const
{
return t;
}
int main()
{
Ch b1 = 11;
// Ch total = 11 + b1; //调用operator int() 将 对象 b1 转化为整数
Ch total = Ch(11) + b1; //调用 Ch(int m)将 11转化为 11 转化为 Ch对象
return 0;
}