01fruit.cpp

来自「一、教学目的: 能理解C++中运算符重载的需要性」· C++ 代码 · 共 24 行

CPP
24
字号
#include<iostream.h>
class Fruit
{
public:
	void Eat(){cout<<"Can be eaten.\n";};
	void Taste(){cout<<"Taste is good.\n";};
};
class Apple:public Fruit
{
public:
	void Shape(){cout<<"The shape is a circle.\n";};
	void Color(){cout<<"Different kinds of color.\n";};
};
void main()
{
	Fruit fruit1;
	fruit1.Eat();
	fruit1.Taste();
	Apple apple1;
	apple1.Eat();
	apple1.Taste();
	apple1.Shape();
	apple1.Color();
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?