vc-study-2

来源:互联网 发布:手机淘宝改好评链接 编辑:程序博客网 时间:2024/05/22 16:58

//仅仅只是C++简单代码的编写

#include <iostream.h>

class animal
{
public:
animal()
{
   cout<<"animal construct"<<endl;
}
~animal()
{
   cout<<"animal 析构函数"<<endl;
}
void eat()
{
   cout<<"animal eat"<<endl;
}
void sleep()
{
   cout<<"animal sleep"<<endl;
}
void breathe()
{
   cout<<"animal breathe"<<endl;
}
};

class fish : public animal
{
public:
fish()
{
   cout<<"fish construct"<<endl;
}
~fish()
{
   cout<<"fish 析构函数"<<endl;
}

void breathe()
{
   cout<<"fish breathe"<endl;
}
};

void main()
{
animal an;
an.breathe();
fish fh;
fh.breathe();

}

原创粉丝点击