填空题

main函数中发生编译错误的语句是______。 #include<iostream.h> class A { public: int a; const int b; A( ):a(10),b(20){} void fun( )const { cout<<"a="<<a<<"\tb="<<b<<endl; } }; void main( ) { A obj1; const A*ptr=new A; ptr=&obj1; ptr->a=100; ptr->fun( ); }

【参考答案】

ptr->a=100;
<上一题 目录 下一题>
热门 试题

填空题
下列程序从保存整数的文本文件”c:Sample.dat”中依次取出每个数据并显示出来,同时统计并显示出所有数据的个数。程序划线处的表达式为______。#include<stream.h>#include<stdlib.h>void main( ){ifstream fin( c:Sample.dat ,los::nocreate);if(! fin){cout<< 文件无法打开! <<endl;exit(1);}int x,i=0;while(______){cout<<x<< ;i++;}fin.close( );cout<<endl<< 文件中所有整数个数: <<i<<endl;}
填空题
类clasg one在声明func成员函数时发生错误,出错原因是______。class oneprivate:int a;public:void func(two&);};class two{private:int b;friend vold one::func(two&);};void one::func(two&r){a=r.b;}
相关试题
  • 下列程序中的重载函数disp( )发生错误,...
  • 类time可以输出12小时或24小时制的时间...
  • 在下列基类的定义中,有无virtual修饰use成...