C++对象的赋值和复制

#include
using namespace std;
class Myclass{
public:
void set(int x,int y)
{
a=x;
b=y;
}
void show()
{
cout<<a<<" "<<b<<endl;
}
private:
int a,b;
};
int main()
{
Myclass ob1,ob2;
int a,b;
cin>>a>>b;
ob1.set(a,b);
ob1.show() ;
//copy-
ob2=ob1;
ob2.show() ;
return 0;
}

上一篇:不要压缩windows系统盘


下一篇:Facebook Hacker Cup 2015 Round 1 --- Winning at Sports