I'm having some issues doing that.
I'm trying to make a template class which holds a template list I made. The list consists of template nodes (another template class I made).
My problem is that in some places (not everywhere) the compiler says that I'm trying to access private members of the node's class.
For example, if I define my node like this:
1 2 3 4 5 6 7 8 9 10
|
template<class T>
class CoefNode {
private:
T coef;
int exp;
CoefNode* next;
CoefNode* prev;
public:
// Cunstructor
};
|
And I use that class when I allocate new CoefNodes while adding items to the list (the template class is CoefList).
So for example, when I try to create the destructor, I wrote this:
1 2 3 4 5 6 7
|
~CoefList() {
CoefNode<T>* pIterator = head;
while (pIterator) {
pIterator = pIterator->next;
delete pIterator->prev;
}
}
|
And then the compiler gives me these errors:
genpoly.H: In destructor `CoefList<T>::~CoefList() [with T = Complex]':
poly_main.C:40: instantiated from here
genpoly.H:13: error: `CoefNode<Complex>*CoefNode<Complex>::next' is private
genpoly.H:94: error: within this context
genpoly.H:14: error: `CoefNode<Complex>*CoefNode<Complex>::prev' is private
genpoly.H:95: error: within this context
What am I doing wrong?
Thanks.