⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bird.hpp

📁 深入浅出设计模式(书配套c++源代码)。包含20个设计模式的c++实现。
💻 HPP
字号:
#ifndef	_HFDP_CPP_FLYWEIGHT_FOWLWEIGHT_BIRD_HPP_#define _HFDP_CPP_FLYWEIGHT_FOWLWEIGHT_BIRD_HPP_#include "FowlWeight.hpp"namespace HeadFirstDesignPatterns {namespace FlyWeight {namespace FowlWeight {// Unshared ConcreteFlyweightclass Bird : public Fowl {	private: const Fowl* _fowl;	private: int _number;	private: double _weight;	private: Bird( const Bird& ); // Disable copy constructor    private: void operator=( const Bird& ); // Disable assignment operator	public: Bird( const Fowl* fowl, int number = 0, double weight = 0.0 ) :		_fowl( fowl ), _number( number ), _weight( weight ) { assert( fowl );	}	public: void quack() const { assert( _fowl );		_fowl->quack();	}	public: void swim() const { assert( _fowl );		_fowl->swim();	}	public: double getWeight() const {		return _weight;	}	public: double getNumber() const {		return _number;	}	public: std::string toString() const { assert( _fowl );		std::stringstream value; 		value << "Bird #"<< _number + 1 << ", ";		value << "weighs " << _weight << " pounds, ";		value << "is a " << _fowl->toString();		return value.str();	}};} // namespace FowlWeight} // namespace FlyWeight} // namespace HeadFirstDesignPatterns#endif

⌨️ 快捷键说明

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