首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
如下程序的输出结果是______。 #include<iostream> using namespace std; class Pet{ char name[10]; public: Pet(char*nan
如下程序的输出结果是______。 #include<iostream> using namespace std; class Pet{ char name[10]; public: Pet(char*nan
admin
2012-01-20
44
问题
如下程序的输出结果是______。
#include<iostream>
using namespace std;
class Pet{
char name[10];
public:
Pet(char*nanle){strcpy(this->name,name);}
const char*getName( )const{return name;}
virtual void call( )eonst=0;
};
class Dog:public Pet{
public:
Dog(char*name):Pet(name){ }
void call( )eonst{cout<<"汪汪叫";}
};
class Cat:public Pet{
public:
Cat(char*name):Pet(name){ }
void call( )const{eout<<"喵喵叫";}
};
int main( ){
Pet*petl=new Dog("哈克"),*pet2=new Cat("吉米");
eout<<petl->getName( );petl->call( );eout<<endl;
cout<<pet2->getName( );pet2->call( );eout<<endl;
return 0;
}
选项
答案
哈克汪汪叫 吉米喵喵叫
解析
转载请注明原文地址:https://kaotiyun.com/show/iRVp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有以下程序:#include<stdio.h>voidfun1(char*p){char*q;q=p;while(*q!=’\0’){(*q)++;q++;}main(){chara[]={"Program"},*p;p=&
有如下程序#include<stdio.h>main(){inti;for(i=0;i<5;i++)putchar(’Z’-i);}程序运行后的输出结果是
有以下程序:#inc1udemain()fintx;scanf("%d",&x);if(x
下列叙述中正确的是()。
下列方法中,不属于软件调试方法的是()。
下列叙述中正确的是()。
在数据库系统的内都结构体系中,索引属于()。
如果关系R中有4个属性和3个元组,关系S中有3个属性和5个元组,则R×S的属性个数和元组个数分别是______。
为满足运算符+的可交换性,必须将其重载为【】。
随机试题
下列哪条违背了医师的道德义务
A.便血为主,痔块不脱出肛门外B.便血加重,排便时痔块脱出、便后能自行回缩复位C.偶有便血,但腹压增加时痔块即可脱出,且不能自行回缩D.突感肛门剧痛,肛管皮下可见暗紫色肿物E.便时、便后两次疼痛高峰一期内痔()
月经周期第8-11天最易受孕。()
毛泽东在《论十大关系》中确立的社会主义建设的基本方针是()。
拜占庭中等教育学习的基本内容是()。
古老的五刑是指()。
TheDeclineofU.S.ImmigrationApplicationImmigrantsaren’tseekingU.S.citizenshipasoftenthesedays—notsincetheAme
(2010下项管)在大项目管理中,往往要在项目各阶段进行项目范围确认。有关范围确认的叙述,正确的是______。
Insportthesexesareseparate.Womenandmendonotrunorswiminthesameraces.Womenarelessstrongthanmen.Thatatlea
AccordingtotheWorldHealthOrganization,airpollutionkillsabout________aroundtheworldeachyear.
最新回复
(
0
)