Dlaczego ten kod w takiej formie działa, a po odkomentowaniu pokazuje błąd:
16: variable or field 'c' declared void
16: expected ')' before 'f'
In function 'int main()':
26: 'c' was not declared in this scope
26: expected primary-expression before 'int'
26: expected ';' before 'int'
=== Build finished: 5 errors, 0 warnings ===
kod:
#include <stdio.h>
template<class T>
class A
{
public:
typedef void (A<T>::*Func)();
void d()
{
printf("Udalo sie!");
}
};
/*
template<class T>
void c(A<T>::Func f)
{
A<T> test;
(test.*f)();
}/**/
int main()
{
A<int>::Func d = &A<int>::d;
//c<int>(&A<int>::d);
return 0;
}