#include <iostream.h>
class Test
{ private:
int x,y;
public:
Test() {x=y=0;}
void Setxy(int x,int y) {______}
void show(){______}
};
void main()
{Test ptr;
ptr.Setxy(5,10);
ptr.show();
}
答案:(*this).x=x; (*this).y=y;,cout<<x<<"+"<<y<<"="<<x+y<<endl;
[解析]形参同数据成员同名,使用this来访问。
川公网安备 51010402001278号