#include <stdio.h>
#include <iostream>
using namespace std;
class Stock1{
public:
void Sell(){ cout<<"stock1 sell\n";};
void Buy(){ cout<<"stock1 out\n";};
};
class Stock2{
public:
void Sell(){ cout<<"stock2 sell\n";};
void Buy(){ cout<<"stock2 out\n";};
};
class Stock3{
public:
void Sell(){ cout<<"stock3 sell\n";};
void Buy(){ cout<<"stock3 out\n";};
};
class Fund{
Stock1 * gu1;
Stock2 * gu2;
Stock3 * gu3;
public:
Fund(){
gu1 = new Stock1();
gu2 = new Stock2();
gu3 = new Stock3();
}
void sell(){
gu1->Sell();
gu2->Sell();
gu3->Sell();
};
void buy(){
gu1->Buy();
gu2->Buy();
gu3->Buy();
}
};
void testLesson8(){
Fund * fund = new Fund();
fund->buy();
fund->sell();
}
簡(jiǎn)單的不能再簡(jiǎn)單了辆布,為了使技術(shù)分層時(shí)將每層的技術(shù)做一定的封裝享言,可以讓高層用戶不需要改動(dòng)