填空题
下列程序中的this指针的作用是 【13】 。
#include <iostream. h>
class Sample
{
int n;
static int st;
public,
Sample() {}
Sample(int m) {n=m; st=m+10;}
void Change(int k) {st=st+k;}
void AddValue(int m)
{
Sample s,
s. n=n+m;
*this=s;
}
void disp( ) {cout<<"n="<<n<<";st="<<st<<end1;}
};
int Sample: :st=0
void main()
{
Sample s1(10),s2(10)
s1. disp()
s1. AddValue(5),
s2. Change(100);
s1. disp();
s2. disp()
}
【参考答案】
修改本对象的值