代码拉取完成,页面将自动刷新
#include "iostream"
#include "delegates.h"
static void print(int n) {
std::cout << "print:" << n << std::endl;
}
static void print() {
std::cout << "print:xx" << std::endl;
}
int main(int, char**) {
class test {
public:
delegates::Delegate0 d1;
delegates::Delegate1<int> on;
delegates::Delegate2<int, bool> on2;
void Add(delegates::IDelegate2<int, bool>* d) {
on2 += d;
}
};
class hello {
public:
static void print0(int n) {
std::cout << "h0:" << n << std::endl;
}
static void print1(int n) {
std::cout << "h1:" << n << std::endl;
}
void print3(int n) {
std::cout << "h3:" << n << std::endl;
}
void print4(int n) {
std::cout << "h4:" << n << std::endl;
}
void print() {
std::cout << "hh:xxx" << std::endl;
}
void print_arg2(int a, bool b) {
std::cout << "print_arg2\t"<<a << (b ? "true" : "false") << std::endl;
}
void print_arg3(int a, bool b) {
std::cout << "print_arg3\t"<<a << (b ? "true" : "false") << std::endl;
}
};
test t;
hello h;
t.on += delegates::New(&hello::print0);
t.on.connect(&hello::print1);
t.on += delegates::New(&h, &hello::print4);
t.on.connect(&h, &hello::print3);
t.on(1);
t.on -= delegates::New(&hello::print1);
t.on.disconnect(&hello::print0);
t.on(2);
t.d1.connect(&h, &hello::print);
t.d1.connect(print);
t.d1();
t.Add(delegates::New(&h, &hello::print_arg3));
t.on2.connect(&h, &hello::print_arg2);
t.on2(1, true);
return 1;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。