网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
main函数中发生编译错误的语句是______。 include class A { public: int a; const i

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( );

}


参考答案

更多 “ main函数中发生编译错误的语句是______。 include class A { public: int a; const i 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( );} ” 相关考题
考题 下面程序错误的语句是①include ②void main( 0③{④int * p = new int[1] ;⑤p =9;⑥co 下面程序错误的语句是 ①#include < iostream.h> ②void main( 0 ③{ ④ int * p = new int[1] ; ⑤ p =9; ⑥ cout <<*p <<end1; ⑦ delete [ ] p; ⑧ }A.④B.⑤C.⑥D.⑦

考题 下面程序错误的语句是 ① include ② void main( ) ③ { ④ int * p=new int[1] ; ⑤ p 下面程序错误的语句是① #include<iostream.h>② void main( )③ {④ int * p=new int[1] ;⑤ p=9;⑥ cout < < * p < <endl;⑦ delete[ ] p;⑧ }A.④B.⑤C.⑥D.⑦

考题 下列程序的运行结果是 includeclass Location{private:int X.Y;public:void init(i 下列程序的运行结果是 #include<iostream.h> class Location{ private: int X.Y; public: void init(int=0,int=0); void valueX(int val){X=val;} int valueX( ){ return X;} void valueYA.5 0 6 4B.0 0 6 4C.5 0 6 2D.0 0 6 2

考题 有如下程序:include using namespace std;class Base{protected:int i;public:int 有如下程序: #include <iostream.h> using namespace std; class Base { protected: int i; public: int j; }; class Derived:public Base { int m; public: int n; }; int main() { Derived d; d.i=0; //[1] d.j=0; //[2] d.m=0; //[3] d.n=0; //[4] return 0; } 其中主函数中有两个赋值语句有错,这两个错误的赋值语句是( )。A.[1]和 [2]B.[1]和[3]C.[2]和[3]D.[2]和[4]

考题 下面程序的运行结果为includeclass A{ int num;public: A(int){num=i;} A(ABm){num 下面程序的运行结果为 #include<iostream.h> class A { int num; public: A(int){num=i;} A(ABm){num=a.num++;} void print(){cout<<num;} }; void main() { Aa(1),b(a); a.print(); b.print(); }A.11B.12C.21D.22

考题 分析以下程序的执行结果【】。include class S{ int A[10]; public: int operato 分析以下程序的执行结果【 】。include <iostream. h>class S{int A[10];public:int operator () (int);};int S: :operator() (int x) {return A[x];}void main() {S a;int i,j;for (i=0; i<10; i++)a(i)=i*2;for (i=0; i<10; i++)cout<<a(i)<<" ";cout<<end1; }

考题 下面程序错误的语句是①include ②void main()③{④int * p=new int[1]⑤p=9⑥cout 下面程序错误的语句是①#include<iostream.h>②void main()③{④ int * p=new int[1]⑤ p=9⑥ cout<<* p<<end1;⑦ delete []p;⑧}A.④B.⑤C.⑥D.⑦

考题 类中包含了一个静态成员函数,则main函数中和P.f1(P);语句具有同样功能的语句为______。include<iostream.h>class M{public:M(int A){A=a;B+=a;}static void f1(M m);private:int A;static int B;};void M::f1(M m){cout<<“A=“<<m.A((end1;cout<<“B=”<<m.B<<en

考题 如下程序编译时发生错误,错误的原因是show函数实现语句错误,则正确的语句应该为______。include<iostream.h>class test{private:int hum;public:test(int);void show( );};test::test(int n){num=n;}test::show( ){cout<<num<<endl;}void main( ){test T(10):T.show( );}