Can someone explain to me why this does not compile and how should I write it correctly?
#include <iostream>
using namespace std;
template <typename T>
struct Foo
{
template <typename U>
struct Bar
{
};
};
template <typename T, typename U>
void func(Foo<T>::Bar<U>& lhs)
{
cout << "working" << endl;
}
int main()
{
Foo<int>::Bar<char> a;
func(a);
return 0;
}
I get the following compiler error:
main.cpp:23:19: error: variable or field ‘func’ declared void
void func(Foo<T>::Bar<U>& lhs)