I am learning c++ and in the past two week, I started learning and practicing about Function Pointers and Templates.. but it came to my mind if I can have a template function pointer..
So, here is what I have coded as I started my practice to try to understand whats going on... but Visual Studio 2013 is not accepting my function call in the main method... not sure what I am doing wrong and its saying that my function pointer is undefined but I thought it was?
Code:
#include <iostream>
template<class T>
int foo(T& x){
return x * 500;
}
template<class T>
T (*myFunc)(T) = foo;
int main(){
std::cout << myFunc(7) << std::endl;
system("pause");
return 0;
}
Well, I really hope you guys can help me to understand if what I want to do is possible and which is the proper way and why?
Thanks a lot.. if required more details my questions please let me know!!!