( 35 )有如下程序:
#include <iostream>
using namespace std;
Class B{
public:
B(int xx):x(xx) {++cout; x+=10;}
virtual void show() const
{cout<<count<< ' _ ' <<x<<endl;}
protected:
static int count;
private:
int x;
};
class D:public B{
public:
D(int xx,int yy):B(xx),y(yy) {++count; y+=100;}
virtual void show() const
{cout<<count<< ' _ ' <<y<<endl;}
private:
int y;
};
int B::count=0;
int main(){
B *ptr=new D(10,20);
ptr->show();
delete ptr;
return 0;
}
运行时的输出结果是
A ) 1_120
B ) 2_120
C ) 1_20
D ) 2_20
第1题:
如下程序的输出结果是 #include<iostream> void fun(int & X,inty){intt=x;x=y;y=t;} int main( ){ int a[2]={23,42}; fun(a[1],a[0]); std::cout<<a[0]<<","<<a[1]<<std::endl; return 0; }
A.42,42
B.23,23
C.23,42
D.42,23
第2题:
第3题:
00330038003000301585067361821下列程序段执行结果是___________。 x = 1 print(type(x)) x = 1.0 print(type(x)) x = '1.0' print(type(x)
A.<class 'int'> <class 'float'> <class 'str'>
B.<class 'float'> <class 'int'> <class 'str'>
C.<class 'str'> <class 'float'> <class 'int'>
D.<class 'str'> <class 'int'> <class 'float'>
第4题:
使用VC6打开考生文件夹下的工程test35_1,此工程包含一个源程序文件test35_1.cpp,但该程序运行有问题,请改正程序中的错误,使该程序的输出结果为:
400
40
源程序文件test35_1.cpp清单如下:
include <iostream.h>
class Student
{
public:
Student(int xx){x=xx;}
virtual float calcTuition();
/***************** found *****************/
private:
int x;
};
float Student::calcTuition()
{
return float(x'x);
}
/***************** found *****************/
class GraduateStudent::public Student
{
public:
/***************** found *****************/
GraduateStudent(int xx) ::Student(xx){}
virtual float calcTuition();
};
float GraduateStudent::calcTuition()
{
return float(x*2);
}
void main()
{
Student s(20);
GraduateStudent gs(20);
cout<<s.calcTuition()<<end1;
cout<<gs.calcTuition()<<end1;
}
第5题:
第6题:
下列程序段执行结果是___________。 x = 1 print(type(x)) x = 1.0 print(type(x)) x = '1.0' print(type(x)
A.<class 'int'> <class 'float'> <class 'str'>
B.<class 'float'> <class 'int'> <class 'str'>
C.<class 'str'> <class 'float'> <class 'int'>
D.<class 'str'> <class 'int'> <class 'float'>