填空题

在下面的类定义中,this指针的用途是 【11】 。
#include <iostream. h>
class Sample

int x,y;
public:
Sample(int i,int j)x=i;y=j;
void asstgn(Sample sa):
;
void Sample: :assign(Sample p)

if (this! =&p)

x=p.x;
y=p.y;

【参考答案】

防止对类对象自己给自己赋值
<上一题 目录 下一题>
热门 试题

填空题
根据三角形的基本定理完成填空,则表达式为 【8】 。 #include<iostream. h> #include<math. h> void main() double a,b,c,s,area; cout<< 请输入三角形三边a,b,c: <<end1; cin>>a>b>>c; if(______) s=(a+b+c) 2; area=sqrt(s*(s-a)*(s-b)* (s-c)), cout<< 三角形的面积为: <<area; else cout<< 不能构成三角形! <<end1;
填空题
下列程序的运行结果为 【9】 。 #include<iostream, h> void main( ) int i; for(i=1; i<6;i++)if(i==3) break: com<< i= <<i<<end1;
相关试题
  • 参照函数模板的写法,完成非模板函数的定义...
  • 下列程序中的this指针的作用是 【13】 ...
  • 下列程序的运行结果为 【14】 。 #in...
  • 下列程序的运行结果是 【15】 。 #in...
  • 下列程序编译错误,因为add函数返回值是一...