类重载
来源:互联网 发布:php 字符串比较 编辑:程序博客网 时间:2024/04/29 04:20
域操作符::
基类为Animal,子类为Fish
Animal.h
#include"stdafx.h"
class Animal
{
public:
Animal(int height, int weigh);
~Animal();
void eat();
void sleep();
virtual void breath();
}:
Animal.cpp
#include"stdafx.h"
#include"iostream.h"
using namespace std;
#include"Animal.h"
Animal::Animal(int height, int weigh)
{
}
Animal::~Animal()
{
}
void Animal::eat()
{
cout<<...<<endl;
}
void Animal::fish()
{
cout<<...<<endl;
}
void Animal::breath()
{
cout<<...<<endl;
}
Fish.h
#include"stdafx.h"
class Fish : public Animal
{
public:
Fish();
~Fish();
void breath();
};
Fish.cpp
#include"stdafx.h"
#include"iostream.h"
using namespace std;
#include"Animal.h"
#include"Fish.h"
Fish::Fish() : Animal(400,300)
{
};
Fish::~Fish()
{
};
void Fish::breath()
{
cout<<...<<endl;
};
MAIN
#include"stdafx.h"
#include"iostream.h"
using namespace std;
#include"Animal.h"
#include"Fish.h"
void fn(Animal *pAn)
{
pAn->breath();
}
int _tmain(int argc, _TCHAR* argv[])
{
Fish fi;
Animal *pAn;
pAn = &fi;
fn(pAn);
}
- 类重载
- 类重载
- override/重载 接口/类
- 重载TCLCL中的类
- CTreeCtrl重载类
- Point类重载
- 抽象类的重载
- 类 操作符 重载
- python 类 成员,重载
- 时间类输出重载
- 时间类输出重载
- 类运算符重载
- oop_day02_类、重载_20150810
- 分数类重载
- 类和对象&重载
- 重载 QApplication 类
- Python 类,函数重载
- 类中的函数重载
- 浅谈ASP.NET的Postback
- 最大子序列和问题(一维,二维)
- 判别分析实例
- MyEclipse 中使用 CVS 进行版本控制
- Ajax显示一个浮动的窗口(实例)
- 类重载
- 编码与过滤流与包装流 2011-4-24
- GCC笔记
- Filter及FilterChain的使用详解
- for loop initial declaration used outside C99 mode
- Ajax收缩级联菜单(实例)
- How to remove an ASM instance and its corresponding database(s) on WINDOWS
- pthread_cond_wait的工作机制
- Die young at 80