首页 > 其他 > 详细

ChainOfResponsibility

时间:2014-12-16 18:26:49      阅读:242      评论:0      收藏:0      [点我收藏+]
#include <iostream>

using namespace std;



class Chain
{
public:
    bool Handle() { return false; }
};

class Level1 : public Chain
{
public:
    bool Handle()
    {
        cout<<"Level1::true"<<endl;
        return true;

    }
};

class Level2 : public Level1
{
public:
    bool Handle()
    {
        cout<<"Level2::Handle"<<endl;
        return Level1::Handle();
    }
};

class Level3 : public Level2
{
public:
    bool Handle()
    {
        cout<<"Level3::Handle"<<endl;
        return Level2::Handle();
    }
};



int main(int argc, char *argv[])
{
    Level3 level3;
    level3.Handle();


    return 0;
}

 

ChainOfResponsibility

原文:http://www.cnblogs.com/stanley198610281217/p/4167448.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!