Protected and inheritance

So now my derived class isn't accessing protected members of a base class. Or, perhaps more likely, I'm making a mistake. Here's some code. First the base class.

1
2
3
4
5
6
7
8
9
10
11
12
13
#include "linkednodedef.h"

template <class Type>
class linkedListType {
public:
       //various public members
protected:
          int count;        
          nodeType<Type> *first;
          nodeType<Type> *last;
private:
       //private members
};


And for the derived:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "linkedlistthings.h"
#include "linkednodedef.h"

template <class Type>
class unorderedLinkedList : public linkedListType<Type> {
public:
       bool search(const Type& searchItem) const;  //determines if it's in list
       //et al... let's just look at this member for now
};

template <class Type>
bool unorderedLinkedList<Type>::search(const Type& searchItem) const
{ 
     nodeType<Type> *current;    //pointer to traverse the list
     bool found = false;
     current = first;   //set current to point to the first node in the list
     
     while (current != NULL && !found)   //searching the list...
        if (current->info == searchItem)   //searchItem is found
          return true;
        else
            current = current->link;       //make current point to next node if not found
     return found;
}


Problem is found in the boldface line. I get an error that says first is undeclared. Yet, unorderedLinkedList publicly inherits class linkedListType, which first is a protected pointer.

And a couple more details, linkedlistthings.h is now only the header for class linkedListType. I called it linkedlistthings.h because initially it included definitions of nodes and another class, but I moved them to linkednodedef.h.
Thanks alot.
Topic archived. No new replies allowed.