I am trying to call a member function from a member template function but it complains about not having overloads for member function. How do i fix it? Below is the test code.
class Test
{
public:
template <typename T>
void foo(int i, T param)
{
switch (i)
{
case 1:
fun(param);
break;
case 2:
bar(param);
}
}
void fun(string p)
{
std::cout << "string: " << p << std::endl;
}
void bar(double p)
{
std::cout << "double: " << p << std::endl;
}
};
int main() {
Test t;
t.foo(1, "hello");
t.foo(2, 100.0);
return 0;
}
error: no matching function for call to 'Test::fun(double&)'
Aucun commentaire:
Enregistrer un commentaire