网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
如下程序的输出结果是______。 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;

}


参考答案

更多 “ 如下程序的输出结果是______。 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;} ” 相关考题
考题 有以下程序:includeincludeusingnameSpacestd;classperson{ intage; Char*nam 有以下程序:include <iostream>include <string>using nameSpace std;class person{int age;Char * name;public:person ( int i, Char * str ){int j;j = strlen( str ) + 1;name = new char[ j ];strcpy( name, str );age = i;}~person(){delete name;cout<<"D";}void display(){cout<<name<<":"<<age;}};int main(){person demo( 30,"Smith" );demo.display();return 0;}则该程序的输出结果为:【 】。

考题 以下程序的输出结果是【】。 includevoid main() {char *p= "12345678" , *r;long *q; 以下程序的输出结果是【 】。include<iostream. h>void main() {char *p= "12345678" , *r;long *q;q=(long *)p;q++;r= (char *) q:cout<<r;}

考题 以下程序的输出结果是()。includevoid func(char**m) {++m:cout 以下程序的输出结果是( )。 #include<iostream.h> void func(char**m) { ++m: cout<<*m<<endl; } void main() { static char*a[]={"MORNING","AFTERTOON","EVENING"}; char**n; n=a: func(n); }A.为空B.MORNINGC.AFTERTOOND.EVENING

考题 若有如下程序:include using namespace std;int main(){ char *p="abcdefgh",*r; lon 若有如下程序: #include <iostream> using namespace std; int main() { char *p="abcdefgh",*r; long *q; q=(long *)p; q++; r=(char *)q; cout<<r<<end1; return 0; } 上述程序的输出结果是( )。A.abcdefghB.0C.abcdD.efgh

考题 如下程序的输出结果是includevoid fun(int x=y;y=t;}int main(){in 如下程序的输出结果是 #include<iostream> void fun(int & X,inty){intt=x;x=y;y=t;} int main( ){ int a[2]={23,42}; fun(a[1],a[0]); std::cout<<a[0]<<","<<a[1]<<std::endl; return 0; }A.42,42B.23,23C.23,42D.42,23

考题 有如下程序: 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;}程序的输出结果是______。

考题 若有如下程序段: include using namespace std; int main() {char*p="abcdefgh",*r;l 若有如下程序段:include <iostream>using namespace std;int main(){char *p="abcdefgh",*r;long *q;q=(long *)p;q++;r=(char *)q;cout<<r<<end1;return 0;}该程序的输出结果是______。

考题 以下程序的输出结果是()。includeincludeusing namespace std;void func(cha 以下程序的输出结果是( )。 #include<iostream> #include<stdlib> using namespace std; void func(char **m) { ++m; cout<<*m<<endl; } main() { static char *a[]={"MORNING","AFTERNOON","EVENING"); char **n; n=a; func(n); system("PAUSE"); return 0; }A.为空B.MORNINGC.AFTERNOOND.EVENING

考题 下列程序的输出结果是()。includevoid main(){char*Str;str="testI";cout 下列程序的输出结果是( )。 #include<iostream.h> void main() { char*Str; str="testI"; cout<<str[5]; }A.test!B.testC.空字符D.异常