题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2023-11-04 03:57:56

[单项选择]下面程序有注释的语句中,错误的语句是( )。 #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 <"的相关试题:

[单项选择]下面程序有注释的语句中,错误的语句是( )。 #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 show B( ){cout<< "this is B!";} }; void main( ){ A ia,*piA; B ib,*piB; piA=ia; //第一个测试语句 piA=&ib; //第二个测试语句 piA->showA( ); //第三个测试语句 piA->showB( ); //第四个测试语句 }
A. 第一个测试语句
B. 第二个测试语句
C. 第三个测试语句
D. 第四个测试语句
[填空题]在下面横线上填上适当的语句,完成程序。 #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】
[填空题]下列程序的输出结果为2,请将程序补充完整。
#include <iostream>
using namespaee 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; } };
[填空题]如下程序执行后的输出结果是 【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; }
[填空题]下列程序的输出结果是______。 #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; 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<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>
#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.h> class A{ private: int xl; protected: int x2; public: int x3; }; class B: public A{ private: int b1; protected: int b2; public: int b3; void disp( ){cout<<x1<<b2<<end1;} //A void set(int i){x3=i;} //B }; void main( ) B bb; bb. a3=10 //C bb. b3=10 //D }
[单项选择]下面程序中错误之处是 ______。
#include<iostream.h>
class A
private:
int xl;
protected:
int x2;
public:
int x3;
;
class B: public A
private:
int b1;
protected:
int b2;
public:
int b3;
void disp( )cout<<x1<<b2<<end1; //A
void set(int i)x3=i; //B
;
void main( )
B bb;
bb. a3=10 //C
bb. b3=10 //D

[填空题]下面程序的执行结果是 【15】 。 #include <iostream> #include <iomanip> using namespace std; void main( ) { cout<<setfill(’x’)<<setw(10); cout<<"Hello"<<end1;
[单项选择]下面程序的功能是( )。
#include <iostream>
#include <string>
using namespace std;
int main ( )

int i=1, n=0;
char s[80],*p;
p=s;
strcpy(p,"It is a book..");
for (; *p !=’ /0’ ;p++)

if(*p==’’)
i=0;
else if (i==0)
n++; i=1;

cout<<"n=" <<n<<end1;
return 0;

A. 统计字符串中的单词个数
B. 统计字符串中的空格个数
C. 统计字符串中的字母个数
D. 统计字符串中的全部字符个数

我来回答:

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

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码