yo/stl/examples/plus.cc
raw| 1 | #include <iostream> |
| 2 | #include <string> |
| 3 | #include <functional> |
| 4 | using namespace std; |
| 5 | |
| 6 | int main(int argc, char **argv) |
| 7 | { |
| 8 | plus<size_t> uAdd; // function object to add size_ts |
| 9 | |
| 10 | cout << "3 + 5 = " << uAdd(3, 5) << '\n'; |
| 11 | |
| 12 | plus<string> sAdd; // function object to add strings |
| 13 | |
| 14 | cout << "argv[0] + argv[1] = " << sAdd(argv[0], argv[1]) << '\n'; |
| 15 | } |
| 16 | /* |
| 17 | Output when called as: a.out going |
| 18 | |
| 19 | 3 + 5 = 8 |
| 20 | argv[0] + argv[1] = a.outgoing |
| 21 | */ |