R
Roy Yao
Why the following code let my compiler complain an overloaded function
Init()?
// code begin
template<class T> class BicircularList
{
template<class T> class Iterator;
template<class T> class ChainNode
{
friend Iterator<T>;
// ...
};
// ...
public:
template<class T> class Iterator
{
public:
T* Init(const BicircularList<T>& list);
T* Next();
private:
ChainNode<T> *m_pHead;
ChainNode<T> *m_pCur;
};
// ...
}
template<class T>
T* BicircularList<T>::Iterator<T>::Init(const BicircularList<T>& list)
{
m_pHead = const_cast<ChainNode<T> *> (&list.m_tNode);
m_pCur = m_pHead->m_pNext;
return (m_pCur!=m_pHead ? &m_pCur->m_tData : 0);
}
// end of code
Here is the error message:
error C2244: 'BicircularList<T>::Iterator<T>::Init' : unable to resolve
function overload
Who can help me? Thanks!
Best regards.
Roy
Init()?
// code begin
template<class T> class BicircularList
{
template<class T> class Iterator;
template<class T> class ChainNode
{
friend Iterator<T>;
// ...
};
// ...
public:
template<class T> class Iterator
{
public:
T* Init(const BicircularList<T>& list);
T* Next();
private:
ChainNode<T> *m_pHead;
ChainNode<T> *m_pCur;
};
// ...
}
template<class T>
T* BicircularList<T>::Iterator<T>::Init(const BicircularList<T>& list)
{
m_pHead = const_cast<ChainNode<T> *> (&list.m_tNode);
m_pCur = m_pHead->m_pNext;
return (m_pCur!=m_pHead ? &m_pCur->m_tData : 0);
}
// end of code
Here is the error message:
error C2244: 'BicircularList<T>::Iterator<T>::Init' : unable to resolve
function overload
Who can help me? Thanks!
Best regards.
Roy