如下程序的输出结果是______。
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;
}
第1题:
如下程序的输出结果是 #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,42
B.23,23
C.23,42
D.42,23
第2题:
若有如下程序段:
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;
}
该程序的输出结果是______。
第3题:
下列程序的输出结果是( )。 #include<iostream.h> void main() { char*Str; str="testI"; cout<<str[5]; }
A.test!
B.test
C.空字符
D.异常
第4题:
有如下程序:
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;
}
程序的输出结果是______。
第5题:
以下程序的输出结果是( )。 #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.MORNING
C.AFTERNOON
D.EVENING