010 返回什么才好呢

#include <iostream>
using namespace std;
class A {
public:
	int val;

	A(int n):val(n) {

    }
    A():val(123){}

    A & GetObj() {
        return *this;
    }
};
int main()
{
	int m,n;
	A a;
	cout << a.val << endl;
	while(cin >> m >> n) {
		a.GetObj() = m;
		cout << a.val << endl;
		a.GetObj() = A(n);
		cout << a.val<< endl;
	}
	return 0;
}

posted @ 2022-02-19 22:43  icefield817  阅读(31)  评论(0编辑  收藏  举报