That is the dog()name is Henry.

题目
单选题
That is the dog()name is Henry.
A

whose

B

who

C

whom

D

which

如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

如下程序的输出结果是______。 include using namespace std; class Pet{ char nam

如下程序的输出结果是______。

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;

}


正确答案:哈克汪汪叫 吉米喵喵叫
哈克汪汪叫 吉米喵喵叫

第2题:

A: Whose dog is it? B: ( )our dog. ( )name is Rex.

A. It's…It's

B. Its… Its

C. It's… Its


答案: C

第3题:

That is the dog () name is Henry.

A、whose

B、who

C、which


参考答案:A

第4题:

A: Whose dog is it? B:()our dog. () name is Rex

AIt’s;It’s

BIts;Its

CIt’s;Its


C

第5题:

有如下程序: include using namespace std; class Pet{ char name[10]; public: Pet(c

有如下程序:

include<iostream>

using namespace std;

class Pet{

char name[10];

public:

Pet(char*name){strcpy(this->name,name);}

const char*getName()const {return name;}

virtual void call()const=0;

};

class Dog:public Pet{

public:

Dog(char*name):Pet(name){}

void call()const{cout<<"汪汪叫":}

};

class Cat:public Pet{

public:

Cat(char*name):Pet(name){}

void call()const{cout<<"喵喵叫";}

};

int main(){

Pet*pet1=new Dog("哈克"),*pet2=new Cat("吉米");

cout<<pet1->getName();pet1->call();cout<<end1;

cout<<pet2->getName();pet2->call();cout<<end1;

return 0;

}

程序的输出结果是______。


正确答案:哈克汪汪叫 吉米喵喵叫
哈克汪汪叫 吉米喵喵叫 解析:此题考查的是虚函数与多态性。在成员函数的声明前面加上virual关键字,即可把函数声明为虚函数;在C++中,一个基类指针可以用于指向它的派生类对象,而且通过这样的指针调用虚函数时,被调用的是该指针实际所指向的对象类的那个重定义版本。即若基类和派生类中存在一模一样的成员函数,通过该基类指针调用这样的成员函数时,若这个成员函数被定义成虚函数,那么就调用派生类中的;否则就调用基类中的。本题中,在f()函数中,此题中,void call()在基类中被声明为虚函数,在主函数中,语句Pet*pet1=new Dog("哈克"),*pet2=new Cat("吉米");定义了基类的指针per1和pet2,并让它们分别指向派生类对象Dog和Cat。所以通过该指针调用call()时运行的是派生类的版本,分别输出哈克和吉米;而通过该指针调用 getName()运行的是基类的版本,分别输出汪汪叫和喵喵叫。

第6题:

清使用VC6或使用【答题】菜单打开考生文件夹projl下的工程projl,此工程中包含了类Pets(“宠物”) 和主函数main的定义。程序中位于每个“//ERROR****found ****”之后的一行语句有错误,请加以改 正。改正后程序的输出结果应为: Name:sonny Type:dog Name:John Type:dog Name:Danny Typc:cat Name:John Type:dog 注意:只修改每个“//ERROR ****found ****”下的那一行,不要改动程序中的其他内容。 include<iostream> using namespace sm; enum Pets_type{d09,cat,bird,fish}; class Pets{ private: char *name; Pets_type type; public: Pets(const char *name=”sonny”,Pets_type type=dog); Pets&operator=(const Pets&s); ~Pets; void showeonst;}; Pets::Pets(eonst char$naIne,Pets_type type) //构造函数 { This ->name=new char[strlen(name)+1]; strcpy(this一>name,name); //ERROR *********found********* type=type; }{ Pets::~Pets//析构函数,释放name所指向的字符串 { //ERROR *********found********* name=’/0‘; } Pets&Pets::0perator=(const Pets&s){ if(&s==this)//确保不要向自身赋值 return *this; delete[]name; name=new char[strlen(S.name)+1];//ERROR *********found********* strcpy(this一>nmne,name); type=S.type: return *this;} void Pets::showconst cout<<“Name:”<<name<<”Type:”: Pets mypetl,mypet2(’’John”,dog);


正确答案:
(1)this一>type=type;
(2)delete[]name;
(3)strepy(this->name,s.name);

第7题:

publicclassPet{privateStringname;publicPet(Stringname){this.name=name;}publicvoidspeak(){System.out.print(name);}}publicclassDogextendsPet{publicDog(Stringname){super(name);}publicvoidspeak(){super.speak();System.out.print(Dog”);}}执行代码Petpet=newDog(京巴”);pet.speak();后输出的内容是哪项?()

A.京巴

B.京巴Dog

C.null

D.Dog京巴


参考答案:B

第8题:

29. The Browns tlunk that a small dog_________.

A. doesn-t need any room to keep .

B. can help them watch their house

C. eats less food than a bigger one

D. usually has a beautiful name


正确答案:B
29.B【解析】由第五段第二句、第三句可知。

第9题:

That is the dog()name is Henry.

Awhose

Bwho

Cwhom

Dwhich


A

第10题:

A: Whose dog is it? B:()our dog. () name is Rex

  • A、It’s;It’s
  • B、Its;Its
  • C、It’s;Its

正确答案:C

更多相关问题