题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2024-05-28 23:29:22

[单项选择]有如下程序:
#include<iostream>
#include<string>
using namespace std;
class MyBag
public:
MyBag(string br,string cr):brand( br), color(cr)++count;
~MyBag( )--count;
static int GetCount( ) return count;
pnvate:
string brand,color;
static int count;
;
int main( )
MyBag one("CityLife","Gray"),two("Micky","Red");
cout<<MyBag::CetCount( );
return 0;

若程序运行时的输出结果为2,则横线处缺失的语句是______。
A. int count=0;
B. static int count=0;
C. int MyBag::count=0;
D. static int MyBag::count=0;

更多"有如下程序: #include<iostream> #includ"的相关试题:

[单项选择]有如下程序:
#include<iostream>
#include<string>
using namespace std;
class Person
public:
Person(string n):name(n)cout<<’P’;
pnvate:
string name;
;
class Date
public:
Date(int y=2012,int m=12,int d=21):year(y),month(m),day(d)cout<<’D’;
private:
int year,month,day;
;
class Student:public Person
public:
Student(string n,int y,int m,int d,char c):birthday(y,m,d),sex(c),Person(n)cout<<’S’;
private:
Date birthday;
char sex;
;
int main( )
Student stul("Zhang",1990,10,1,’F’);
return 0;

运行时的输出结果是______。
A. S
B. PS
C. DPS
D. PDS
[填空题]如下程序执行后的输出结果是 【14】 。 #include <iostream> using namespace std; class Base { public: Base(int x,int y) { a=x; b=y; } void Show( ) { cout<<"Base: "<<a<< ’,’ <<b<<" "; } private: int a,b; }; class Derived : public Base { public: Derived(int x, int y, int z) : Base(x,y),c(z) { } void Show( ) { cout<<"Derived:"<<c<<end1; } private: int c; }; int main( ) { Base b(100,100),*pb; Derived d(10,20,30); pb=&b; pb->Show( ); pb=&d; pb->Show( ); return 0; }
[填空题]下列程序的输出结果为2,请将程序补充完整。 #include <iostream> using namespace std; class Base { public: ______void fun( ) {cout<<1;} }; class Derived:public Base { public: void fun( ){cout<<2;} }; int main( ) { Base*p=new Derived; p->fun( ); delete p; return 0; }
[填空题]请在下列程序的横线处填写正确的语句。 #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; } };
[填空题]在下面横线上填上适当的语句,完成程序。 #include <iostream> using namespace std; class Base { int x; public: Base(int i) { x=i;} ~Base( ){} }; class Derived: public Base { public: ______∥完成类 Derive构造函数的定义 }; int main( ) { Derived Obj; return 0; } 在横线处应填入的语句是 【9】
[填空题]下列程序的输出结果是______。 #include <iostream> using namespace std; template<typename T> T fun(T a,T b) { return (a<=b)a:b;) int main( ) { cout<<fun(3, 6)<<’,’<<fun(3.14F,6.28F) <<end1; return 0;
[单项选择]下面程序有注释的语句中,错误的语句是( )。 #include <iostream> using namespace std; class A{ int a; public: void show A( ){cout<<"this is A!";} }; class B:public A{ int b; public: void showB( ){cout<<"this is B!";} }; void main( ){ A ia,*piA; B ib,*piB; piA=&ia; //第一个测试语句 piA=&ib; //第二个测试语句 piB=&ia; //第三个测试语句 piB=&ib; //第四个测试语句 }
A. 第一个测试语句
B. 第二个测试语句
C. 第三个测试语句
D. 第四个测试语句
[单项选择]应在下列程序画线处填入的正确语句是 ( )。 #include <iostream> using namespace std; clas Base { public: void fun( ) { cout<<"Base::fun"<<end1; } }; class Derived : public Base { void fun( ) { ________________//显示调用基类的函数 fun( ) cout<<"Derived::fun"<<end1; } };
A. fun();
B. Basfun();
C. Base::fun();
D. Base->fun();
[单项选择]有以下程序:
#include <iostream>
#include <math>
using namespace std;
class point

private:
double x;
double y;
public:
point(double a,double b)

x=a;
y=b;

friend double distance(point a,point b) ;
;
double distance(point a,point b)

return sqrt ((a.x-b.x)* (a.x-b.x)+(a.y-b.y)*(a.y-b.y));

int main ( )

point pl(1,2);
point p2 (5, 2);
cout<<distance (pl,p2) <<end1;
return 0;

程序运行后的输出结果是( )。
A. 1
B. 5
C. 4
D. 6
[单项选择]有以下程序
#include <iostream>
#include <string>
using namespace std;
class base

private:
char baseName[10];
public:
base ( )

strcpy(baseName,"Base");

virtual char *myName( )

return baseName;

char *className( )

return baseName;

;
class Derived : public base

private:
char derivedName[10];
public:
Derived( )

strcpy(derivedName,"Derived");

char *myName( )

return derivedName;

char *className( )

return derivedName;

;
void showPtr(base &p)

cout<<p.myName ( ) <<" "<<p.className ( );

int main ( )

base bb;
Derived dd;
showPtr(dd);
return 0;

运行后的输出结果为
A. Derived Base
B. Base Base
C. Derived Derived
D. Base Derived
[单项选择]有以下程序:
#include<iostream>
#include<string>
using namespace std;
int main( )

char arr[2][4];
strcpy(arr[0],"you");
strcpy(arr[1],"me");
arr[0][3]=’&’;
cout<<arr[0]<<end1;
return 0;

执行后的输出结果是( )。
A. you&me
B. you
C. me
D. err

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

截图扫码使用小程序[完全免费查看答案]
请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码