bind.cc 288 B

1234567891011121314151617
  1. #include <iostream>
  2. #include <string>
  3. #include <functional>
  4. void print(const std::string& s, int num)
  5. {
  6. std::cout << s << " " << num << std::endl;
  7. }
  8. int main()
  9. {
  10. print("nihao", 10);
  11. auto func = std::bind(print, "nihao", std::placeholders::_1);
  12. func(20);
  13. return 0;
  14. }