填空题

在下面的类定义中,this指针的用途是______。
#include<iostream.h>
class Sample
int x,y;
public:
Sample(int i,int j)x=i;y=j;
void assign(Sample sa);
;
void Sample::assign(Sample p)
if(this!=&p)

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

【参考答案】

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

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