There is something seriously wrong with my C++ compiler today

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
South Africa is kind of a long way to stretch to look at your screen, so I suggest you tell us what the errors are.
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
An hypothesis from this thread:
http://osprey.unisa.ac.za/phorum/read.php?317,102722

Have you included “linkedList.h”?
#include "linkedList.h"
Hello Bopaki,

I think it is time to post the entire header file not just the portion that you think is the problem.

Refer back to helios's message http://www.cplusplus.com/forum/beginner/245091/#msg1084508

I am thinking that there is more going on in this file than what little bit you posted.

Andy
You're not showing us nearly enough code for us to be able to know what the problem is.

Please post a minimal, compilable codeset that exhibits the problem.
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).
Last edited on
Thank you very much to everybody. The program worked very well after putting this-> in front of the protested members.

And again thank you! thank you!! thank you!!!
Topic archived. No new replies allowed.