1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <functional>
class MyClass {
public:
void printSum(int a, int b) const {
std::cout << "Sum: " << a + b << std::endl;
}
};
int main() {
MyClass obj;
// Bind the member function with the object and the first argument fixed to 10
auto boundFunc = std::bind(&MyClass::printSum, &obj, 10, std::placeholders::_1);
boundFunc(5); // Outputs: Sum: 15
return 0;
}
Back to std_bind