zoukankan      html  css  js  c++  java
  • Poco版信号槽

    #include "Poco/BasicEvent.h"
    #include "Poco/Delegate.h"
    #include <iostream>

    using Poco::BasicEvent;
    using Poco::Delegate;
    #include <typeinfo>
    class A
    {
    public:
        BasicEvent<std::string> theEvent;
        void sentToB(std::string message)
        {
            theEvent(this,message);
        }
        void getFromB(const void* pSender,std::string &message)
        {
            std::cout<<"cur class is:"<<typeid(A).name()<<std::endl;
            std::cout<<"B says:"<<message<<std::endl;
        }
    };
    class B
    {
    public:
        BasicEvent<std::string> theEvent;
        void sentToA(std::string message)
        {
            theEvent(this,message);
        }
        void getFromA(const void* pSender,std::string &message)
        {
            std::cout<<"cur class is:"<<typeid(B).name()<<std::endl;
            std::cout<<"A says:"<<message<<std::endl;
        }
    };
    int main(int argc,char ** argv)
    {
        A aDemo;
        B bDemo;

        aDemo.theEvent += Delegate<B,std::string>(&bDemo,&B::getFromA);
        bDemo.theEvent += Delegate<A,std::string>(&aDemo,&A::getFromB);

        aDemo.sentToB("bendan");
        bDemo.sentToA("zhen sha");
        return 0;
    }
    -lPocoFoundation

    生活的残酷,让我们习惯了忘记疲倦,一直奔向远方,追寻着自己的梦想。
  • 相关阅读:
    POJ 2068 Nim(博弈论)
    POJ 2311 Cutting Game (Multi-Nim)
    CodeForces 144B Meeting
    ZUFEOJ 2147 07染色带谜题
    CodeForces 779E Bitwise Formula
    CodeForces 779D String Game
    CodeForces 779C Dishonest Sellers
    CodeForces 779B Weird Rounding
    CodeForces 779A Pupils Redistribution
    HRBUST 1313 火影忍者之~静音
  • 原文地址:https://www.cnblogs.com/L-Arikes/p/4969422.html
Copyright © 2011-2022 走看看