C++ (Qt)class A{public: signal<void> TellSmth; }; class B : public SlotObject{public: signal<void> TellSmth; B() { a.TellSmth.connect(&TellSmth); }private: A a;}
C++ (Qt)#include <iostream>#include <string>#include "signal_slot.h" void some_func(int a, float f, const std::string &str, double &x) { std::cout << "x = " << x << std::endl; std::cout << "a = " << a << " f = " << f << " str = " << str << std::endl; x += 123.456; std::cout << "x = " << x << std::endl;} class object : public ssc::trackable{public: void print(const std::string &text) const { std::cout << text << std::endl; } int sum(int x, int y, int z) const { int s = x + y + z; std::cout << "sum = " << s << std::endl; return s; } }; int main(){ object obj; ssc::signal<const std::string &> sig1; sig1.connect(&obj, &object::print); ssc::signal<long, float, int> sig3; sig3.connect(&obj, &object::sum); ssc::signal<int, double, const std::string &, double&> sig4; sig4.connect(some_func); sig1("hello word!"); sig3(1, 3.14, 2); double x = 0.0; sig4(1, 3.14, "hello word!", x); return 0;}