下面程序的结果为【7】。
#include
void main()
{
int a=1,b=2:
bool c=1;
if((a >b)‖C)cout<<”true”<
else
cout <<”false”<
}
阅读以下程序 #include(iostream.h> voidmain() { charline[10]; cin>>line; cout<<1ine<<endl; } 如运行时输入“Thisisanexample.<CR>”,则程序的输出结果是()。
A.This
B.Thisis
C.Thisisa
D.Thisisanexample
有如下程序:
#include<iostrealn>
using namespace std
class A{
public:
virtual void f(){cout<<1;}
void g(){cout<<2;}
};
class B:public A{
public:
virtual void f(){cout<<3;}
void g(){cout<<4;)
};
void show(A&A){a.f();a.g();}
int main(){
B b;
show(B);
return 0;
}
运行时的输出结果是
A.12
B.34
C.14
D.32
(27 )有如下程序:
#include
using namespace std;
class test {
private:
int a;
public:
test () {cout<< ” constructor ” <<ENDL;}
test (int a ) {cout<<A<<ENDL;}
test (const test & _test )
{
a=_testa;
cout<< ” copy constructor ” <<ENDL;
}
test () {cout<< ” destructor ” <<ENDL;}
};
int main ()
}
test A (3 )
return0;
运行时输出的结果是
A ) 3
B ) constructor
destruclor
C ) copy constructor
dstructor
D ) 3
destruclor
根据下面的程序,可以在主程序中使用的合法语句是()。 #include <iostream> using namespace std; class Person{ int age; voidtest(){} public: Person(intage){this->age=age;} void ShowAge(){cout<<"the Person's age is",<<age;} }; void main(){ Person wang(23); }
A.wang.age=45
B.wang.wang(45)
C.wang.ShowAge()
D.wang.test()
若语句: cout<<seffill('>')<<setw(5)<<3141512<<sctw(5)<<"OK!"; 是程序中第1个输出语句,则输出结果是()。
A.3141512>>OK!
B.31415120K!>>
C.314150K!>>
D.31415>>OK!
A.3141512>>OK!
B.31415120K!>>
C.314150K!>>
D.31415>>OK!
对于语句cout<<endl<<x;中的各个组成部分,下列叙述中错误的是
A.“cout”是一个输出流对象
B.“endl”的作用是输出回车换行
C.“x”是一个变量
D.“<<”称作提取运算符
下列程序中画线处应填入的语句是
class Base
{
public:
void fun(){cout <<”Base of fun”<
};
class Derived:public Base
{
void fun()
{
//显示基类的成员函数fun
cout <<”Derived of fun”<
};
A.fun();
B.Base. fun();
C.Base::fun();
D.Base- >fun-: