this指针的问题以及引用的问题

#include <iostream>

using namespace std;

class A {

public:

 int val;

 

 A(int

 n=123){

  val=n;

 }

 

 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;

}

这里getobj()函数为什么用引用。

为什么返回this指针会使a.val就等于m的值了