From bb89e3f35d3ea515166f390cf7968c716c569614 Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Tue, 14 Nov 2023 13:49:55 -0500 Subject: [PATCH] adding the functor program --- lectures/21_hash_tables_II/functor.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 lectures/21_hash_tables_II/functor.cpp diff --git a/lectures/21_hash_tables_II/functor.cpp b/lectures/21_hash_tables_II/functor.cpp new file mode 100644 index 0000000..25bddb5 --- /dev/null +++ b/lectures/21_hash_tables_II/functor.cpp @@ -0,0 +1,17 @@ +#include + +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; +} +