题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2024-02-13 21:26:05

[填空题]#include<iostream.h>
class Bas
public:
~Bas( )cout<<"Bas construct"<<endl;
virtual void f( )=0;

class Dev:public Bas
public:
~Dev( )cout<<"Bas construct"<<endl;
virtual void f( )cout<<"Dev::f"<<endl;

void main( )
Bas*a=new Bas( );
Dev p;
a=&p;
a->f( );

更多"#include<iostream.h> class Bas "的相关试题:

[单项选择]下列类的定义中,有( )处语法错误。 class Base { public: Base( ){} Base(int i) { data=i; } private: int data; }; class Derive : public Base { public: Derive( ) : Base(0) {} Derive (int x) { d=x; } void setvalue(int i) { data=i; } private: d; };
A. 1
B. 2
C. 3
D. 4
[填空题]下列程序的输出结果是非曲直 【15】
#include<iostream, h>
class base int x, y;
public:
base(int i, int j)x=i; y=j;
virtual int add( )return x+ y;
;
class three: public base int z;
public:
three(int i, int j, int k) :base(i, j)z=k;
int add( ) return (base:: add( )+z);
;
void main( ) three * q=new three(lO,20,30);
cout<<q->add( )<<end1;

[填空题]下列程序的输出结果是______。
#include<iostream.h>
class base

int x,y;
public:
base(int i,int j)x=i;y=j;
virtual int add( )return x+y;
;
class three:public base

int z;
public:
three(int i,int j,int k):base(i,j)z=k;)
int add( )return(base::add( )+z);
;
void main( )

three*q=new three(10,20,30);
cout<<q->add( )<<endl;

[填空题]下列程序的运行结果是______。
#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)

Base*pd=new Base;
pd=new Derived;
pd->f(’a’);

[填空题]

[程序]
#include
#include
class B{
public:
B(char *s){name=new char[strlen(s)+1];strcpy(name,s);}
virtual void print( ){cout<<"姓名;"<
protected:
char *name;
};
class P1:public B{
public:
P1(char *s,float g):B(s){x=g;}
void print(int i)
{ cout<<"姓名:"<年薪:"<万元。 /n";}
private:
float x;
};
class P2:public B{
public:
P2(char *s,int n):B(s){ num=n;}
void print( ){cout<<"姓名;"<月工资:"<元。/n";}
private:
int num;
};
void main(void)
{
B *p;
B x("张明");
P1 y("王虎",4.2);
P2 z("李建国",5000);
p=&x;p->print( );
p=&y;p->print( );
y.print(1);
p=&z;p->print( );
}
执行以上程序后输出的第二行是() ,第四行是()。


[单项选择]下列程序的输出结果是
#include
class Myclass
public:Myclass(int i=0,intj=0)
x=i;
y=j;

void show( ) cout < < "x=" < < x < < " " < "y=" < < y < < end1;
void show( )const cout < < "x=" < < " " < < "y=’ < < y < < end1;
privated:
int x; int y;

void main( )
Myclass my1(3,4);
const my2(7,8);
my1.show( );my2.show( );
A. x=4,y=3;x=7,y=8
B. x=3,y=4;x=7,y=8
C. x=7,y=8;x=4,y=3
D. x=8,y=7;x=7,y=8
[单项选择]阅读下面程序
public class ForLoopStatement
 public static void main(String[] args)
   int i,j;
   for(i=1;i<5;i++)                       //i循环
     for(j=1;j<=i;j++)System.out.print(i+"*"+j+"="+i*j+" "); //j循环
System.out.println( );



程序完成后,i循环和J循环执行的次数分别是
A. 4,10
B. 8,9
C. 9,8
D. 10,10
[单项选择]请阅读下面程序
public class ExampleStringBuffer
public static void main (String[]args)
StringBuffer sb=new StringBuffer("test");
System.out.printIn("buffer="+sb);
System, out.printIn("length="+sb.length( ));


程序运行结果中在“length=”后输出的值是______。
A. 10
B. 4
C. 20
D. 30

我来回答:

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

订单号:

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