I am trying to pass a function as parameter to class, but getting error as use of class template requires template argument list
.
#include <iostream>
void f_global ()
{
std::cout << "In function global\n";
}
template<typename F>
class A
{
public:
F f1;
A(const int var1, F fun1) : a(var1), f1(fun1) {}
void f2();
private:
int a;
};
void A::f2()
{
std::cout << "in A::f2()\n";
}
int main()
{
A obj(5,f_global);
obj.f2();
}
I am trying to use auto template deduction feature while passing function from obj
What are template deduction guides and when should we use them?