c++方面的程序

来源:百度知道 编辑:UC知道 时间:2024/06/30 06:25:51
#include"iostream"
using namespace std;

class Felid{
public:
virtual char sound();
};
class cat:public Felid{
char x;
public:
cat(char xx){x=xx;}
//cout<<"the sound is "<<x<<endl;

};

class leopard:public Felid{
char y;
public:
leopard(char yy){y=yy;}
//cout<<"the sound is"<<y<<endl;

};

int main(){
Felid*a;
char m,o;
cat s(m);
a=&s;

leopard t(o);
a=&t;

system("PAUSE");
}

#include"iostream"
using namespace std;

class Felid
{
public:
Felid()
{
}
virtual void sound()
{
cout<<'a'<<endl;
}
};

class cat:public Felid
{
char x;
public:
cat(char xx)
{
x=xx;
}
void sound()
{
cout<<x<<endl;
}

//cout<<"the sound is "<<x<<endl;

};

class leopard:public Felid
{
char y;
public:
leopard(char yy)
{
y=yy;
}
void sound()
{
cout<<y<<endl;
}
//cout<<"the sound is"<<y<<endl;

};

void main(){
Felid*a;
c