?class animal?{?public:? void eat( )? { cout<<"animal eat"<<" /> ?class animal?{?public:? void eat( )? { cout<<"animal eat"<<" />

全文预览

08FJ04防空地下室固定柴油电站图集.pdf

上传者:科技星球 |  格式:pdf  |  页数:78 |  大小:0KB

文档介绍
<<"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Р派生类重写基类的功能

收藏

分享

举报
下载此文档