题目
下面程序段的输出为 #nclude"stdio.h" main() { printf("%d\n",12<<2);}
A.0
B.47
C.48
D.24
第1题
有如下程序: #nclude<iostream> using namespace std; int main { void function(double val); double val; function(val); cout<<val; return 0; } void function(double val) } val=3;} 编译运行这个程序将出现的情况是()。
A.编译出错,无法运行
B.输出:3
C.输出:3.0
D.输出一个不确定的数
第2题
有如下程序:
nclude<iostream>
using namespace std;
class Animal{
public:
virtual char*getType()const{return“Animal”;}
virtual char*getVoice()const{return“Voice”;}
};
class Dog:public Animal{
public:
char*getType()const{rgturn“Dog”;}
char*getVoice()const{retum“Woof”;}
};
void type(Animal&A){cout<<a.getType();}
void speak(AnimalA){cout<<a.getVoice();}
int main(){
Dog d.type(D);tout<<“speak”;speak(D);cout<<endl;
return 0;
}
运行时的输出结果是【 】
第3题
A.编译时出现语法错误,不能生成可执行文件
B.运行时一定输出:llle value at P:9
C.运行时一定输出:llle value at P:*9
D.运行时有可能出错
第4题
A.4,3,2,1
B.4,3,6,7,2,1
C.4,3,6,2,1
D.1,2,3,4
第5题
有如下程序:#nclude <iostream>using namespace std;class Base{ public:void fun1() {cout << "Base\n"; }virtual void fun2() {cout << "Base\n"; }};class Derived: public Base{ public:void fun1() {cout << "Derived\n"; }void fun2() {cout << "Derived\n"; }} void f(Base& b) { B. fun1(); B. fun2(); }int main(){Derived obj;f(obj);return 0;}
A.Base Base
B.Base Derived
C.Derived Base
D.Derived Derived
第6题
下面程序的输出结果为【 】。
include <iostream>
using namespace std;
void initialize(int printNo,int state=0);
void initialize(int printNo=1,int state);
int main()
{
initialize();
return 0;
}
void initialize(int printNo, int state)
{
cout<<printNo<<","<<state<<end1;
}
第7题
A.2
B.23
C.234
D.编译错误
第8题
A.2
B.23
C.234
D.编译错误
第9题
若下面程序运行时输出结果为
1,A,10.1
2,B,3.5
include <iostream>
using namespace std;
int main()
{
void test(int, char, doubie【 】);
test(1, 'A', 10.1 );
test(2, 'B');
return 0;
}
void test(int a, char b, double c)
{
cout<<a<<','<<b<<','<<c<<endl;
}
第10题
A.2
B.23
C.234
D.编译错误
为了保护您的账号安全,请在“赏学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!