题目内容 (请给出正确答案)
[主观题]

有如下程序: include<iostream> using namespaee std;class Animal{ public: virtual char*g

有如下程序:

include<iostream>

using namespaee std;c lass Animal{

public:

virtual char*getType()const{return"Animal";}

virtual char*getVoice()const{return"Voice";}

};

class Dog:public Animal{

public:

char*getType()const{return"Dog";}

char*getVoice()eonst{return"Woof";}

};

void type(Animal&A) {cout<<a.getType();}

void speak(Animal A) {eout<<a.getVoice();}

int main(){

Dog d;type(D) ;cout<<"speak";speak(D) ;cout< return 0;

}

程序的输出结果是______。

提问人:网友tmwlnjtu 发布时间:2022-01-07
参考答案
查看官方参考答案
如搜索结果不匹配,请 联系老师 获取答案
更多“有如下程序: include<iostream> using…”相关的问题
第1题
有如下程序,请问其输出是____。 class Base { //基类 public: Base() { cout << "1" ; } ~Base() { } }; class Derived : public Base { //派生类 public: Derived() { Base(); cout << "3"; } ~Derived() { } }; int main(int argc, char* argv[]) { Derived od; return 0; }
点击查看答案
第2题
有如下程序:

#include

voidmain()

{charch[2][5]={"6937","8254"),*p[2];

inti,j,s=0;

for(i=0;i<2;i++)p[i]=ch[i];

for(i=0;i<2;i++)

for(j=0;p[i][j]$amp;>apos;$\0';j+=2)

s=10*s+p[i][j]-'0';

cout$amp;该程序的输出结果是()。

A.69825

B.63825

C.6385

D.693825

点击查看答案
第3题
若有如下程序: int sub(int m) { if(m==1||m==0) return 2; else return(sub(m-1)*sub(m-2));} main() { int n; scanf("%d",&n); printf("%d",sub(n)); } 如果从键盘输入4<回车>,则程序运行后的输出结果是()。

A.8

B.16

C.24

D.32

点击查看答案
第4题
有如下程序: #include<iostream> using namespace std; class Complex { double re,im; public: Complex(double r,double i):re(r),im(i){} double real()const{return re;} double image()const{return im;} Complex& operator+=(Complex a) { re+=a.re; im+=a.im; return *this; } }; ostream& operator<<(ostream& s,const Complex& z) { return s<<'('<<z.real()<<','<<z.image()<<')'; } int main() { Complex x(1,2),y(2,3); tout<<(x+=y)<<endl; return 0; } 执行这个程序的输出结果是()。

A.(1,-2)

B.(2,3)

C.(3,5)

D.(3,1)

点击查看答案
第5题
1)#include 2)#include 3)using namespace std;4)doub...

1)#include< iostream >

2)#include< cmath >

3)using namespace std;

4)double max(double x,doubley)

5){

6)if(x>y)

7)return x;

8)else

9)return y;

10)}

11)int main()

12){

13)doublea,b,c;

14)cout<<" input two numbers:"; 15)cin >>a >>b;

16)c=max(a,b);

17)cout<<" the squart of max imum="<< sqrt( c ); 18)}

执行完第14行后,命令提示符窗口中输出的结果是:()

点击查看答案
第6题
有如下程序:#include <iostream> using namespace std; class ONE { int c; public: ONE(): c(0) { cout<<1; } one(int n): c(n) { }; two one onel; one2; public: two(int m) : one2(m) int main() t(4); return 0; 运行时的输出结果是( )> A、3

B、23

C、123

D、213

点击查看答案
第7题
有如下程序: #include<iostream> using namespace std; class Base { public: void funl(){cout<<"Basea";} virtual void fun2(){tout<<"Base\n";} }; class Derived:public Base { public: void funl() {cout<<"Derived\n"; } void fun2() {cout<<"Derived\n"; } }; void f(Base& b) {b.funl(); b.fun2(); } int main() { Derived obj; f(obj); return 0; } 执行这个程序的输出结果是

A.Base Base

B.Base Derived

C.Derived Base

D.Derived Derived

点击查看答案
第8题
以下程序中的select()函数功能是:在N行M列的二维数组中选出一个最大值作为函数值返回,并通过形参传回此最大值的行下标。请填空完成此程序。

include<iostream>

define N 3

define M 3

using namespace std;

int select(int a[N][M],int *n)

{

int i,j,row=0,colum=0;

for(i=0;i<N;i++)

for(i=0;j<M;j++)

if(a[i][j]>a[row][colum])

{

row=i;

colum=j;

}

*n=【 】;

return 【 】;

}

int main()

{

int a[N][M]={9,11,23,6,1,15,9,17,20};

int max,n;

max=select(a,&n);

cout<<"max="<<max<<"line="<<n<<end1;

return 0;

}

点击查看答案
第9题
有如下程序:

include <iostream>

using namespace std;

int strle(char a[],char b[])

{

int num=O,n=O;

while (* (a+num) !='\0')

num++;

while (b [n] )

{

* (a+num)=b [n];

num++;

n++;

}

return(num);

}

int main ()

{

char strl[80],str2[80],*p1=str1,*p2=str2;

cin>>p1;

cin>>p2;

cout<<strle(p1,p2)<<end1;

return 0;

}

运行上述程序,如果从键盘输入字符串qwerty和字符串abcd,则程序的输出结果是【 】。

点击查看答案
账号:
你好,尊敬的用户
复制账号
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改
欢迎分享答案

为鼓励登录用户提交答案,简答题每个月将会抽取一批参与作答的用户给予奖励,具体奖励活动请关注官方微信公众号:简答题

简答题官方微信公众号

警告:系统检测到您的账号存在安全风险

为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!

微信搜一搜
简答题
点击打开微信
警告:系统检测到您的账号存在安全风险
抱歉,您的账号因涉嫌违反简答题购买须知被冻结。您可在“简答题”微信公众号中的“官网服务”-“账号解封申请”申请解封,或联系客服
微信搜一搜
简答题
点击打开微信