源码
// 11Inhe_Concept.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "iostream.h"
//考虑一个场景,图书馆有很多书(book),其中,很多事技术类现代书籍(TechBook),也有珍贵的历史文献(HisBook)
//如果一本书丢了,都要进行批评教育,但是,赔偿角度,TechBook原价赔偿,HisBook 100倍赔偿
class Book
{
protected://why not private?
int price;
int id;
char* name;
public:
void Lost()
{
cout << "批评教育" << endl;
}
};
class TechBook : public Book
{
public:
void Lost()
{
Book::Lost();
cout << "give money 1* price" << endl;
}
};