题目内容
下列程序中的this指针的作用是【 】。
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()
}
查看答案
搜索结果不匹配?点我反馈