有人可以为我解释一下 C++ 代码吗?
could someone explain that C++ code for me?
下面代码中的冒号是什么意思?回调函数从何而来?
using void_callback_f = void (*)();
std::vector<void_callback_f> _reload_callbacks;
void Reload() {
for (const auto& callback : _reload_callbacks) {
callback();
}
}
for循环中的冒号是Range-based for loop
的例子
range_expression is evaluated to determine the sequence or range to
iterate. Each element of the sequence, in turn, is dereferenced and
assigned to the variable with the type and name given in
range_declaration.
请查看here了解更多信息
下面代码中的冒号是什么意思?回调函数从何而来?
using void_callback_f = void (*)();
std::vector<void_callback_f> _reload_callbacks;
void Reload() {
for (const auto& callback : _reload_callbacks) {
callback();
}
}
for循环中的冒号是Range-based for loop
range_expression is evaluated to determine the sequence or range to iterate. Each element of the sequence, in turn, is dereferenced and assigned to the variable with the type and name given in range_declaration.
请查看here了解更多信息