class Sample{
public:
Sample( ){ }
~Sample( ){ }
void SetData(int datA) {//将Sample类成员变量data设置成形参的值
______
}
private:
int data;
};
[试题]( 11 )请在如下程序中的空格处填写正确的语句:#include<iostream>using namespace std;class Base{public:void fun(){cout<<"Base fun"<<endl;}};class Derivde:public Base{public:void fun(){___________// 调用基类的函数 fun()cout<<"Derived fun"<<endl;}}
[单选题]在下面的类定义中,错误的语句是( )。 class Sample { public: Sample(int val): //① ~Sample(); //② private: int a=2.5; //③ Sample(): //④ };A.①②③④B.②C.③D.①②③
[单选题]在下面的类定义中,错误的语句是class Sample { public: Sample(int val); //①~Sample(): //②private: int a=2.5; //③Sample(); //④ };A.①②③④B.②C.③D.①②③
[单选题]在下面的类定义中,错误的语句是( )。class Sample { public:Sample(int val); //①~Sample(); //②private: int a=2.5; //③Sample(); //④ };A.①②③④B.②C.③D.①②③
[单选题]下列程序中横线处应填入的语句是( )。 Class Base { public: roid fun(){cout<<“Base of fun”<<endl;) }; class Derived:public Base { void fun() { //显示基类的成员函数fun cout<<“Derived Of fun”<<endl; } };A.fun();B.Base.fun();C.Base::fun();D.Base->fun();
[单选题]下列程序中画线处应填入的语句是 class Base { public: void fun( ){cout<<"Base of fun"<<end1;} }; class Derived:public Base { void fun( ) { ______//显示基类的成员函数fun cout<A.fun( );B.Base.fun( );C.Base: :fun( );D.Base->fun( );
[单选题]下列程序中画线处应填入的语句是 class Base { public: void fun(){cout<<"Base of fun"<<end1:} }; class Derived:public Base { void fun() { _______//显示基类的成员函数fun cout<<"Derived of fun"<<end1; } };A.fun();B.Base.fun();C.Base∷fun();D.Base- >fun();
[单选题]在下列横线处应添加的语句是( )。 class Base{public:void fun(){cout<<"Base::fun"<<end1;}}; class: Derived: public Base { public: void fun() { ______//显示调用基类的fun函数 cout<<"Derived::fun"<<end1; } };A.Derived::funB.Base::fun();C.Pubic::funD.fun();
[主观题](12)有以下程序,请在 (12) 处填写正确语句,使程序可正常编译运行。#include <stdio.h>(12) ;main(){ double x,y,(*p)();scanf("%lf%lf",&x,&y);p=avg;printf("%f/n",(*p)(x,y));}double avg(double a,double b){ return((a+b)/2);}
[单选题]下列程序中下画线处应填入的语句是class Base{public:void fun( ) {cout < < "Baseoffun" < < endl;}};class Derived:public Base{void fun( ){______//显示基类的成员函数funcout < < "Derived of fun" < < endl;}};A.fun( ) ;B.Base. fun( ) ;C.Base: :fun( ) ;D.Base->fun( ) ;