更多"下面程序的执行结果是( )。 #include<iostream>"的相关试题:
[单项选择]下面程序的执行结果是( )。
#include<iostream>
using namespace std;
class building
public:
building( )
building(unsigned stories, float breadths, float lengths)
story = stories; breadth = breadths; length = lengths;
void getstory(void)
cout<<"story is:"<<story<<endl;
void getarea(void)
area = length*breadth*story;cout<<"area is:"<<area<<endl;
private:
unsigned story;
float length;
float breadth;
float area;
;
void main(void)
building b1,b2;building b3(10u,16.6,58.8);
b1.getstory( );
b1.getarea( );
b2.getstory( );
b2.getarea( );
b3.getstory( );
b3.getarea( );
A. story is:0
B. story is:null
C. 前两个对象输出的结果是不定的,后一个对象的结果正确
D. 前两个对象没有初值,因此程序编译时出错
[单项选择]下面程序的输出结果是( )。
#include<iostream>
Using namespace std:
Class Base
public:
Base(int x=0)count<<x;
;
Class Derived:public Base
public:Derved(int x=0count<<x;
private:
Base val;
;
int mina( )
Derived d(1);
return 0;
A. 0
B. 1
C. 01
D. 001
[单项选择]下面程序输出的结果是( )。
#include<iostream>
using namespace std;
int fuc (char *x);
int main( )
cout<<fuc("hello")<<endl;
return 0;
int fuc(char *x)
char *y=x;
while(*y! =’/0’)y++;
return(y-x);
A. 5
B. 6
C. 0
D. 语法错误,不能输出结果
[单项选择]下面程序运行的结果是( )。
#include<iostream>
using namespace std;
class A
protected:
int a;
public:
void input(int i)
a=i;
;
class B
protected:
int a;
public:
void input(int j)
a=j;
;
class C: public A, public B
int x;
public:
void input( )
x=A::a * B::a;cout<<x<<endl;
;
void main( )
C c;
c.A::input(5);
c.B::input(8);
c.input( );
A. 5
B. 8
C. 40
D. 编译出错
[单项选择]下面程序的运算结果是( )。
#include<iostream>
using namespace std;
class A
public:
virtual void fun( )=0;
;
class B:public A
public:
void fun( )
cout<<"new file"<<" ";
;
class C:public A
public:
void fun( )
cout<<"open file"<<" ";
;
void main( )
A a, * p;
B b;C c;
p=&c;
p->fun( );
p=&b;
A. new file open file
B. new file new file
C. 编译出错
D. open file new file
[单项选择]下面程序的输出结果是( )。
#include<iostream>
using namespace std;
void swap(int x[2])
int t;
t=x[0];
x[0]=x[1];
x[1]=t;
void main( )
int a[2]=4,8;
swap(
A. ;
[单项选择]下面程序的运行结果是( )。
#include<iostream>
using namespace std;
class A
public:
virtual~A( )
cout<<"call A::~A( )"<<endl;
;
class B:public A
char * p;
public:
B(int i)
p=new char[i];
~B( )
delete(p);
cout<<"call B::~B( )";
;
void main( )
A * a=new B(8);
delete a;
A. call B::~B()call A::~A()
B. call B::~B()
C. call A::~A()
D. call A::~A()call B::~B()