#include #include using namespace std;class relatives{public: relatives(){} virtual ~relatives(){} virtual bool request(int)=0;};class brother : public relatives{public: brother(){} virtual ~brother(){} bool request(int num) { if (num<100) { cout<<"哥哥给你买"< p_vbuy;public: buysomething() { p_vbuy.push_back(new brother); p_vbuy.push_back(new mother); p_vbuy.push_back(new father); } virtual ~buysomething() { p_vbuy.clear(); } void request(int num) { bool flag=false; for (vector ::iterator it=p_vbuy.begin();it!=p_vbuy.end();it++) { flag=(*it)->request(num); if (flag==true) break; } }};int main(){ buysomething *buy=new buysomething; buy->request(6000); delete buy; system("pause"); return 0;}