Try the following:
template<typename T>
class A
{
public:
class Iterator : public std::iterator<std::forward_iterator_tag, T>
{
public:
virtual void DoSomething() = 0;
};
virtual Iterator * begin() const = 0;
virtual void func() = 0;
};
template<typename T>
class B : public A<T>
{
public:
B() {}
class BIterator : public A<T>::Iterator
{
public:
void DoSomething()
{
std::cout << "Hello world from B::BIterator!";
}
};
A<T>::Iterator * begin() const
{
return new BIterator();
}
virtual void func()
{
}
};
int main(int argc, char * argv[])
{
B<int> b;
A<int>::Iterator * iter = b.begin();
iter->DoSomething();
delete iter;
getchar();
}
, B A<T>::Iterator, . , , A<T> - . , , ?
:
. , , :
A<int>::Iterator iter = b.begin();
, , A<T>::Iterator, . A<T>::Iterator...