在下面程序中,编译出现错误的语句是 ______。 class B { public: B( ){f(); } virtual void f()=0; };A.class BB.public:C.B() {f();}D.virtual void f()=0;
在下面程序中,编译出现错误的语句是 ______。 class B { public: B( ){f(); } virtual void f()=0; };
A.class B
B.public:
C.B() {f();}
D.virtual void f()=0;
相关考题:
在下面程序中,A、B、C、D四句编译时不会出错的是()。include using namespace std;class 在下面程序中,A、B、C、D四句编译时不会出错的是( )。 #include <iostream> using namespace std; class Base{ public: Base(); Base(int e):count(C) {} virtual void print() const = 0; private: int count; }; class Derived :public Base{ public: Derived():Base(0) {} Derived(int C) :Base(C) {} void printt() const{cout<< "Derived"<<endl:} }; void main( ) { Derived d(10); Base *pb; pb = d; //A Base cb= d; Derived dd = *pb; //B Derived cd = cb; //C Base bb = d; //DA.AB.BC.CD.D
下列程序编译时发现pb->f(10);语句出现错误,其原因是______。 include class Base { 下列程序编译时发现pb->f(10);语句出现错误,其原因是______。include<iostream.h>class Base{public:void f(int x){cout<<"Base:"<<x<<endl;)};class Derived:public Base{public:void f(char*str){cout<<"Derived:"<<str<<endl;}};void main(void){Derived*pd=new Derived;Pd->f(10);}
下面程序段中的错误语句是 ______。 class M{ int i; public: void ~AA(int); AA *p; void AA(); void AA(int x){i=x;}; };A.AA *p;B.void ~AA(int);C.void AA(int);D.void AA(int x){i=x;};
在下面程序中,编译时出现错误的是 ______。 Class A //(1) { public: //(2) A(){ f(); //(3) } void B(){ f(); } virtual void f()const=0; //(4) };A.-1B.-2C.-3D.-4
下面程序的结果是 ______。includeclass A{ public:virtual voidfun()=0{};};class 下面程序的结果是 ______。 #include<iostream.h> class A{ public: virtual void fun()=0{}; }; class B:public A{ public: void fun () {cout<< "new file" ;} }; class C: public A{ public: void fun (){cout<<"open file"<< " " } }; class D: public A{ public: void fun () {cout<< "save file\n" ;} }; void main() { A a,*p; B b; C c; D d; p=c; p->fun (); p=b; p->fun (); p=d; p->fun(); }A.new file open file save fileB.new file new file new fileC.编译出错D.open file new file save file
下列程序编译错误,是由于划线处缺少某个语句,该语句是______。 include class A { pr 下列程序编译错误,是由于划线处缺少某个语句,该语句是______。include<iostream.h>class A{private:int numl;public:A( ):numl(0){}A(int i):numl(i){}};class B{private:int num2;public:B( ):num2(0){}B(int i):num2(i){}int my_math(A obj1, B obj2);};int B::my_math(A obj1,B obj2){return(obj1.numl+obj2.num2);}void main(void){A objl(4);B obj,obj2(5);cout<<"obj1+obj2:"<<obj.my_math(obj1,obj2);}
阅读下列说明和C++代码,填写程序中的空(1)~(6),将解答写入答题纸的对应栏内。【说明】以下C++代码实现一个简单绘图工具,绘制不同形状以及不同颜色的图形。部分类及其关系如图6-1所示。【C++代码】#include?#include?using?namespace?std;class?DrawCircle?{??????//绘制圆形,抽象类? ? ? public: (1);//定义参数为?int?radius,?int?x,?inty? ?virtual~DrawCircle()?{?}};class?RedCircle:public?DrawCircle?{????//绘制红色圆形? ? ? ? public: void?drawCircle(intradius,?int?x,?int?y)?{cout??drawCircle?=?drawCircle;? }? ?virtual~shape()?{?}? public:? ?virtual?void?draw()?=?0;};class?Circle:public?Shape?{????//圆形? ? private:? ? ?int?x,y,radius;? ? public:? Circle(int?x,inty,int?radius,DrawCircle?*drawCircle)? (3)? {? this->x?=?x;? ?this->y?=?y;? ? this->radius?=?radius; }? ? ? public:? void?draw(){? drawCircle?-> (4); }};int?main(){Shape?*redCirclenew?Circle(100,100,10,????(5)????);//绘制红色圆形? Shape?*greenCircle=new?Circle(100,100,10, (6)??);//绘制绿色圆形redCircle >draw();? ?greenCircle?->draw();? ?return?0;}
在下面的类定义中,①、②、③、④四句编译时出现错误的是()。 class A //① { public: //② A(){func();}//③ virtual void func()=0; //④ };A.class AB.public:C.A(){ func(); }D.virtual void func()=0 ;
根据C++标准,C++程序的主函数中不写return语句,也能够通过编译,是因为A.编译器会自动生成 return 0;语句B.标准规定了,所有编译器都要为无return语句的main函数生成一个带值的return语句C.编译器会自动生成 return 42;语句D.编译器会自动生成 return;语句E.编译器会自动生成 return main();语句F.在C++中,main()函数类型可以是void类型,所以不用return语句