M
Marko Pyhajarvi
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<MLinkedList<int>::ListNode>', because the type is not yet
defined in function MLinkedList
<int>::~MLinkedList()
Error E2315 mlinkedlist.h 70: 'object' is not a member of
'counted_ptr<MLinkedList<int>::ListNode>', because the type is not yet
defined in function MLinkedList
<int>::~MLinkedList()
Error E2315 mlinkedlist.h 72: 'next' is not a member of
'counted_ptr<MLinkedList<int>::ListNode>', because the type is not yet
defined in function MLinkedList<i
nt>::~MLinkedList()
----------------------------------------------------
template <class T>
MLinkedList<T>::~MLinkedList()
{
counted_ptr<ListNode> *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<ListNode> *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<MLinkedList<T>::ListNode> *first_;
counted_ptr<MLinkedList<T>::ListNode> *current_;
int size_;
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<MLinkedList<int>::ListNode>', because the type is not yet
defined in function MLinkedList
<int>::~MLinkedList()
Error E2315 mlinkedlist.h 70: 'object' is not a member of
'counted_ptr<MLinkedList<int>::ListNode>', because the type is not yet
defined in function MLinkedList
<int>::~MLinkedList()
Error E2315 mlinkedlist.h 72: 'next' is not a member of
'counted_ptr<MLinkedList<int>::ListNode>', because the type is not yet
defined in function MLinkedList<i
nt>::~MLinkedList()
----------------------------------------------------
template <class T>
MLinkedList<T>::~MLinkedList()
{
counted_ptr<ListNode> *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<ListNode> *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<MLinkedList<T>::ListNode> *first_;
counted_ptr<MLinkedList<T>::ListNode> *current_;
int size_;