Can I be helped with these errors that I get with private members in my program:
I get errors with first , last , and count
1 2 3 4 5
protected:
int count; //variable to store the number of list elements
//
nodeType<Type> *first; //pointer to the first node of the list
nodeType<Type> *last; //pointer to the last node of the list
The source code is very long & cannot fit in.
The header file is in LinkedListType.h by DS Malik
The errors on the protected members first, last, and count are my problem: that they were not declared in this scope.
mingw32-g++.exe -c "C:\Martin\MalikDownloads\Chapter 5 Source Code\orderedLinkedListType\Chapter5OrderedLinkedListType\main.cpp" -o "C:\Martin\MalikDownloads\Chapter 5 Source Code\orderedLinkedListType\Chapter5OrderedLinkedListType\main.o"
In file included from C:\Martin\MalikDownloads\Chapter 5 Source Code\orderedLinkedListType\Chapter5OrderedLinkedListType\main.cpp:2:0:
C:\Martin\MalikDownloads\Chapter 5 Source Code\orderedLinkedListType\Chapter5OrderedLinkedListType\orderedLinkedListType.h: In member function 'bool orderedLinkedListType<Type>::search(const Type&)':
C:\Martin\MalikDownloads\Chapter 5 Source Code\orderedLinkedListType\Chapter5OrderedLinkedListType\orderedLinkedListType.h:43:15: error: 'first' was not declared in this scope
C:\Martin\MalikDownloads\Chapter 5 Source Code\orderedLinkedListType\Chapter5OrderedLinkedListType\orderedLinkedListType.h: In member function 'void orderedLinkedListType<Type>::insertNode(const Type&)':
C:\Martin\MalikDownloads\Chapter 5 Source Code\orderedLinkedListType\Chapter5OrderedLinkedListType\orderedLinkedListType.h:74:5: error: 'first' was not declared in this scope
C:\Martin\MalikDownloads\Chapter 5 Source Code\orderedLinkedListType\Chapter5OrderedLinkedListType\orderedLinkedListType.h:77:5: error: 'count' was not declared in this scope
C:\Martin\MalikDownloads\Chapter 5 Source Code\orderedLinkedListType\Chapter5OrderedLinkedListType\orderedLinkedListType.h:97:5: error: 'count' was not declared in this scope
C:\Martin\MalikDownloads\Chapter 5 Source Code\orderedLinkedListType\Chapter5OrderedLinkedListType\orderedLinkedListType.h:103:5: error: 'count' was not declared in this scope
C:\Martin\MalikDownloads\Chapter 5 Source Code\orderedLinkedListType\Chapter5OrderedLinkedListType\orderedLinkedListType.h: In member function 'void orderedLinkedListType<Type>::deleteNode(const Type&)':
C:\Martin\MalikDownloads\Chapter 5 Source Code\orderedLinkedListType\Chapter5OrderedLinkedListType\orderedLinkedListType.h:116:5: error: 'first' was not declared in this scope
C:\Martin\MalikDownloads\Chapter 5 Source Code\orderedLinkedListType\Chapter5OrderedLinkedListType\orderedLinkedListType.h:150:6: error: 'count' was not declared in this scope
Unqualified names will not be looked-up in the base class when the type that you are inheriting from depends on a template parameter. To make it work you can put this-> in front of the name (this->first) or use a qualified name (orderedLinkedListType::first, or LinkedListType<Type>::first).