class CClass {
private:
template<typename T>
using callbacks = std::vector<T>;
using SomeCallback_t = void(__stdcall*)(int, int);
callbacks<SomeCallback_t> vecCallBacks;
public:
inline auto operator += (SomeCallback_t func) -> void {
vecCallBacks.push_back(func);
};
inline auto ProcessCallBack(int a, int b) -> void {
printf("start of calling\n");
for (auto i : vecCallBacks) {
i(a, b);
}
printf("end of calling\n");
};
};
int main()
{
CClass tmp;
int var1 = 10;
tmp += [&](int a, int b)
{
var1++;
printf("%d + %d = %d\n", a, b, a + b);
};
while (true) {
tmp.ProcessCallBack(rand() % 100, rand() % 100);
Sleep(300);
}
return 0;
}