Mam problem z przekazywaniem klas wewnętrznych jako argumenty funkcji. Dla kodu:
template <typename T>
class jakas_klasa
{
public:
struct klasa_wewnetrzna
{
//jakies dane
};
//reszta klasy
};
template <typename T>
void func (typename jakas_klasa<T>::klasa_wewnetrzna x)
{
//kod
}
int main()
{
jakas_klasa<int>::klasa_wewnetrzna x;
func (x);
return 0;
}
kompilator wypluwa:
wd.cpp: In function 'int main()':
wd.cpp9: error: no matching function for call to 'func(jakas_klasa<int>::kla
sa_wewnetrzna&)'
wd.cpp9: note: candidate is:
wd.cpp55: note: template<class T> void func(typename jakas_klasa<T>::klasa_w
ewnetrzna)
Przy zprecyzowaniu w mainie:
int main()
{
jakas_klasa<int>::klasa_wewnetrzna x;
func<int> (x);
return 0;
}
Program się kompiluje i działa, ale chciałbym żeby można było tej funkcji używać bez precyzowania, tak jak to było w listingu wyżej. Jak to zrobić?