赞
踩
示例代码
- #include <iostream>
-
- // 子系统类:鸟
- class Bird {
- public:
- void fly() {
- std::cout << "Bird is flying." << std::endl;
- }
-
- void sing() {
- std::cout << "Bird is singing." << std::endl;
- }
- };
-
- // 外观类:鸟操作
- class BirdFacade {
- private:
- Bird bird;
-
- public:
- void performActions() {
- bird.fly();
- bird.sing();
- }
- };
-
- int main() {
- BirdFacade birdFacade;
- birdFacade.performActions(); // 输出: Bird is flying. Bird is singing.
- return 0;
- }

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。