remotes.cpp
来自「深入浅出设计模式(书配套c++源代码)。包含20个设计模式的c++实现。」· C++ 代码 · 共 30 行
CPP
30 行
#include "Remotes.hpp"
using namespace HeadFirstDesignPatterns::Bridge::Remotes;
int main( int argc, char* argv[] ) {
std::vector< RemoteControl* > remotes;
std::auto_ptr< SonyControl > sonyControl( new SonyControl( "XBR in living room" ) );
remotes.push_back( sonyControl.get() );
std::auto_ptr< RCAControl > rcaControl( new RCAControl( "19 inch in kitchen" ) );
remotes.push_back( rcaControl.get() );
// turn on all tv's
std::vector< RemoteControl* >::iterator iterator;
for( iterator = remotes.begin(); iterator != remotes.end(); iterator++ ) {
( *iterator )->on();
}
sonyControl->nextChannel();
rcaControl->setStation( 35 );
// turn off all tv's
for( iterator = remotes.begin(); iterator != remotes.end(); iterator++ ) {
( *iterator )->off();
}
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?