nested class in template class
Hi,
Can somebody help me, that what's the problame with that code?
1 2 3 4 5 6 7 8 9 10 11 12
|
template <typename T>
class A
{
class B {};
B f(void);
};
template<typename T>
A<T>::B A<T>::f(void)
{
}
|
B is private in A as you've written it.
Thx for answer, but it's not about visibility.
If I write it without template :
1 2 3 4 5 6 7 8 9 10
|
class A
{
class B {};
B f(void);
};
A::B A::f(void)
{
}
|
It works.
The compiler says:
" teszt.cpp:16: error: expected constructor, destructor, or type conversion before 'A' "
It's something that I don't know how to refer to B when A is template.
To compile that, the compiler must know the constructor, destructor and size of B.
I found the answer, it should be:
1 2 3 4 5 6 7 8 9 10 11
|
template<typename T>
class A
{
class B {};
B f(void);
};
template<typename T>
typename A<T>::B A<T>::f(void)
{
}
|
Topic archived. No new replies allowed.