<<"animal breathe"<<endl;? }?};Рclass fish:public animal?{?};Рvoid main( )?{? fish f1;? f1.eat( );?}Рanimal eatР基类Р派生类Р#include <iostream.h>?class animal?{?public:? void eat( )? { cout<<"animal eat"<<endl; }? void sleep( )? { cout<<"animal sleep"<<endl; }? void breathe( )? { cout<<"animal breathe"<<endl; }?};Рclass fish:public animal?{?public:? void swim( )? {?cout<<"fish swim"<<endl;?}?};Рvoid main( )?{? fish f1;? f1.swim( );?}Рfish swimР派生类扩充基类的功能Р#include <iostream.h>?class animal?{?public:? void eat( )? { cout<<"animal eat"<<endl; }? void sleep( )? { cout<<"animal sleep"<<endl; }? void breathe( )? { cout<<"animal breathe"<<endl; }?};Рclass fish:public animal?{?public:? void breathe( )? {?cout<<"fish breathe"<<endl;?}?};Рvoid main( )?{? fish f1;? f1.breathe( );?}Рfish breatheР派生类重写基类的功能