good morning,
could anyone help me with this problem? i have made an abstract
container from which i have inherited a linkedlist class. this
linkedlist uses a smart pointer "counted_ptr<T> ". there is a problem
now, that destructor definition doesn't go through compilation. below is
the code and comment from the compiler.
the problem seems to be that in destructor pointers next_ and object_
are not members of counted_ptr. what confuses me is that this same
doesn't appear in function "clear()" below!!?? i really don't get
understand anymore. do you know where i have made wrong? below is also
the struct which is located inside the linkedlist class.
Error E2315 mlinkedlist.h 69: 'object' is not a member of
'counted_ptr<ML inkedList<int>: :ListNode>', because the type is not yet
defined in function MLinkedList
<int>::~MLinked List()
Error E2315 mlinkedlist.h 70: 'object' is not a member of
'counted_ptr<ML inkedList<int>: :ListNode>', because the type is not yet
defined in function MLinkedList
<int>::~MLinked List()
Error E2315 mlinkedlist.h 72: 'next' is not a member of
'counted_ptr<ML inkedList<int>: :ListNode>', because the type is not yet
defined in function MLinkedList<i
nt>::~MLinkedLi st()
----------------------------------------------------
template <class T>
MLinkedList<T>: :~MLinkedList()
{
counted_ptr<Lis tNode> *removal;
current_ = first_;
while (current_ != 0)
{
if (current_->object != 0)
delete current_->object;
removal = current_;
current_ = current_->next;
delete removal;
removal = 0;
}
}
template <class T>
void MLinkedList<T>: :clear()
{
counted_ptr<Lis tNode> *removal;
current_ = first_;
while (current_ != 0)
{
removal = current_;
current_ = current_->next;
delete removal;
removal = 0;
}
}
struct ListNode
{
T *object;
ListNode *next;
ListNode *previous;
};
counted_ptr<MLi nkedList<T>::Li stNode> *first_;
counted_ptr<MLi nkedList<T>::Li stNode> *current_;
int size_;
----------------------------------------------------
best regards,
--
Marko Pyhäjärvi
ma************* @iki.fi
http://www.iki.fi/~marko.pyhajarvi