-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
52 lines (44 loc) · 773 Bytes
/
main.cpp
File metadata and controls
52 lines (44 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// MIT License
//
// Copyright (c) 2021-2022 有个小小杜
//
// Created by 有个小小杜
//
#include "delegate.h"
#include <iostream>
using namespace xxd;
using namespace std;
DECLARE_FUNCTION_MULTICAST_DELEGATE(FOnAdd, int, int)
class A
{
public:
virtual void Add(int a, int b)
{
cout << a + b + c << endl;
}
private:
int c = 6;
};
class B : public A
{
public:
virtual void Add(int a, int b)
{
cout << a * b << endl;
}
};
void Add(int a, int b)
{
cout << a - b << endl;
}
int main(int argc, const char * argv[])
{
auto a = std::make_shared<A>();
auto b = new B();
FOnAdd d;
d.add_function(&Add);
d.add_safe_obj(a, &A::Add);
d.add_object(b, &B::Add);
d(5, 6);
return 0;
}