DesignPattern/08.BridgePattern/2.Code/main.cpp

27 lines
434 B
C++
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <iostream>
#include "BridgePattern.h"
int main()
{
Game *game;
Phone *phone;
//Jungle买了PhoneA品牌的手机想玩游戏A
phone = new PhoneA();
game = new GameA();
phone->setupGame(game);
phone->play();
printf("++++++++++++++++++++++++++++++++++\n");
//Jungle想在这个手机上玩游戏B
delete game;
game = new GameB();
phone->setupGame(game);
phone->play();
delete phone;
delete game;
system("pause");
return 0;
}