#include <iostream>
using namespace std;
class A
{
public:
A(){i=0;}
A(int x){i=x;}
A(A const& r){i=r.i;}
~A(){}
int get(){return i;}
void set(int x){i=x;}
operator int(){return i;} //int类型转换
private:
int i;
};
int main()
{
A a(55);
int x=10;
x=a;
cout<<x;
a.get();
return 0;
}
把对象赋给int型变量
最新推荐文章于 2021-02-26 14:27:41 发布