///////////////////////////////////////////////////////////////////////////// // PassFunc.cpp - function accepting both function pointer and functor // // // // Jim Fawcett, CSE687 - Object Oriented Design, Demonstration Spring 2013 // ///////////////////////////////////////////////////////////////////////////// #include typedef void (*fptr)(double d); template void testFunction(T t) { std::cout << "\n from function: value is " << t; } template class TestFunctor { public: void operator()(T t) { std::cout << "\n from functor: value is " << t; } }; template void TestArgs(Arg arg) { arg(3.1415927); } int main() { TestArgs(testFunction); TestArgs(TestFunctor()); TestArgs(testFunction); TestArgs(TestFunctor()); std::cout << "\n\n"; return 0; }