0

I have made declaration of pointer first, last & counter made in the header of template base class,but when header is included in the definition of derived class, it occurs error stated that first,last & counter is not declared in this scope. But the header I used to declared first, last and counter is already included in the header and implementation file of derived class.

//template base class
template <class Type>
class linkedListType
{
    .
    .
    .
    protected:
    int counter; //to store no. of elements in the list
    nodeType<Type> *first; //pointer to first node
    nodeType<Type> *last; //pointer to last node
}

//derived class header
#include "linkedListType.h"
using namespace std;

template <class Type>
class unorderedList:public linkedListType<Type>
{
 public:
    bool searchFor(const Type& searchItem) const;
    void insertFirst(const Type& newItem);
    void insertLast (const Type& newItem);
    void deleteNode(const Type& deleteItem);
};

//derived class definition 
template <class Type>
bool unorderedList<Type>::searchFor(const Type& searchItem) const
{
    nodeType<Type> *current; //pointer to traverse the list
    bool found = false;

    current = first; //set current to point to first node
    .
    .
    .
}
Cory Kramer
  • 114,268
  • 16
  • 167
  • 218

0 Answers0