填空题

在下面的类定义中,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; } }

【参考答案】

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

填空题
下列函数的功能是 【7】 。#include<iostream. h>int Func(int a,int b){ if (a>b) return 1;else if(a==b) return 0;else return -1;}
填空题
根据三角形的基本定理完成填空,则表达式为 【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;} elsecout<< 不能构成三角形! <<end1;}
相关试题
  • 下列程序的运行结果为 【14】 。#incl...
  • 下列程序的运行结果是 【15】 。#incl...
  • 参照函数模板的写法,完成非模板函数的定义...
  • 下列程序中的this指针的作用是 【13】 ...
  • 下列程序的运行结果为 【9】 。#includ...