adding the functor program
This commit is contained in:
17
lectures/21_hash_tables_II/functor.cpp
Normal file
17
lectures/21_hash_tables_II/functor.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <iostream>
|
||||
|
||||
class MyFunctor {
|
||||
public:
|
||||
int operator()(int x, int y) {
|
||||
return x + y;
|
||||
}
|
||||
};
|
||||
|
||||
int main() {
|
||||
MyFunctor myFunc;
|
||||
int result = myFunc(3, 4); // This calls the overloaded () operator.
|
||||
// result now holds the value 7.
|
||||
std::cout << "result is " << result << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user