theaterlights.hpp

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

HPP
42
字号
#ifndef	_HFDP_CPP_FACADE_HOME_THEATER_THEATER_LIGHTS_HPP_#define _HFDP_CPP_FACADE_HOME_THEATER_THEATER_LIGHTS_HPP_#include "HomeTheater.hpp"namespace HeadFirstDesignPatterns {namespace Facade {namespace HomeTheater {class TheaterLights {	private: std::string _description;		private: TheaterLights( const TheaterLights& ); // Disable copy constructor	private: void operator=( const TheaterLights& ); // Disable assignment operator	public: TheaterLights( std::string description ) :		_description( description ) {	}	public: void on() {		std::cout << _description.c_str() << " on" << std::endl;	}	public: void off() {		std::cout << _description.c_str() << " off" << std::endl;	}	public: void dim( int level ) {		std::cout << _description.c_str() << " dimming to " << level  << "%" << std::endl;	}	public: std::string toString() {		return _description;	}};} // namespace HomeTheater} // namespace Facade} // namespace HeadFirstDesignPatterns#endif

⌨️ 快捷键说明

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