Met*_*Cat 4 c++ variables class class-variables
我想用 C++ 创建某种事件系统来满足我的需要
我知道你可以使用函数作为其他函数参数
可能我错过了一些东西(但在 C# 中你可以使用事件处理程序来做到这一点)
小智 10
您可以将其存储在指针中。例如
void func(int a) { ... }
void (*ptr)(int) = &func;
(*ptr)(5); // call the function with value 5
Run Code Online (Sandbox Code Playgroud)
ptr 是一个指针,它采用具有一个“int”参数和“void”作为返回类型的函数内存作为值。
| 归档时间: |
|
| 查看次数: |
16070 次 |
| 最近记录: |