gooseadapter.hpp

来自「深入浅出设计模式(书配套c++源代码)。包含20个设计模式的c++实现。」· HPP 代码 · 共 32 行

HPP
32
字号
#ifndef	_HFDP_CPP_COMPOUND_DECORATOR_GOOSE_ADAPTER_HPP_
#define _HFDP_CPP_COMPOUND_DECORATOR_GOOSE_ADAPTER_HPP_

#include "DuckSimulator.hpp"

namespace HeadFirstDesignPatterns {
namespace Compound {
namespace Decorator {

class GooseAdapter : public Quackable {

	private: std::auto_ptr< Goose > _goose;
 
	private: GooseAdapter( const GooseAdapter& ); // Disable copy constructor
    private: void operator=( const GooseAdapter& ); // Disable assignment operator

	public: explicit GooseAdapter( Goose* goose ) :
		_goose( goose ) { assert( goose );
	}
	public: void quack() const {
		_goose->honk();
	}
	public: std::string toString() const {
		return "Goose pretending to be a Duck";
	}
};

} // namespace Decorator
} // namespace Compound
} // namespace HeadFirstDesignPatterns

#endif

⌨️ 快捷键说明

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