Skip to content

3.2节中std::bind示例代码错误 #305

@ilsunshine

Description

@ilsunshine

书籍pdf版本:2024 年 6 月 1 日- 01b64d4
文件路径:book/zh-cn/03-runtime.md
原来代码
int foo(int a, int b, int c) {
;
}
int main() {
// 将参数1,2绑定到函数 foo 上,
// 但使用 std::placeholders::_1 来对第一个参数进行占位
auto bindFoo = std::bind(foo, std::placeholders::_1, 1,2);
// 这时调用 bindFoo 时,只需要提供第一个参数即可
bindFoo(1);
}
中foo函数返回类型为int但没有返回值会导致编译错误,应当将返回类型改为void或者增加返回值

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions