Working with Classes - Error problems

I am writing a program for a class and am specifically working on part of my code. I am trying to write a bool isFull class member function( I believe that is the correct name). Here are the errors:


p2.cpp: In function `void readWords(std::ifstream&, int&, WordList&)':
p2.cpp:128: error: 'class WordList' has no member named 'isFull'


Header file code:
1
2
3
4
5
6
7
//*************************isFull***********************************
//  Name:         isFull
//  Description:  returns true if array is full, returns false if empty
//  Parameters:   
//  Return:       true
//****************************************************************      
    bool isFull();


.cpp file code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//*************************isFull********************************************
//may not have this written right???

	bool WordList::isFull()  {
	
	countW = 0;
      	const int MAX_WORDS = 1000;
		
		if (countW == MAX_WORDS)
		    return(true);		//is full
		else 
		    return(false);		//is not full

	}


The application file code where I am trying to "call" it:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//*************************readWords*******************************************
//  Name:         readWords
//  Description:   reads words into array and the number of times they occur
//  Parameters:   ifstream& inf, recResults
//  Return:       none
//*****************************************************************************
	void readWords(ifstream& inf, int& countW, WordList& theList) {
      
      		string word;
		countW = 0;
                //     --------v-------- is this right?
      		while ((theList.isFull()) && inf >> word) {

              		theList += word;
              		countW++;
      		}
	
      	//cout << "File read" << endl;
	}//function delimiter
Last edited on
Um .. Is the declaration in the header file commented out?
Sorry - no it was there - it was just out in left field. I moved it back.
Does it work now that it isn't part of a comment?
It no longer generates that error - but I guess I really want to know if I am using right when I call it in the application file.

Last edited on
Looks OK to me.
Doesn't isFull() always return false since you set countW to 0?
Yes - I fixed this with some help but the countW being set to 0 was part of the problem.

.h file
1
2
3
4
5
6
7
//*************************isFull*******************************
//  Name:         isFull
//  Description:  returns true if array is full, returns false if empty
//  Parameters:   
//  Return:       true
//************************************************************
    bool isFull();


In the .cpp file:
1
2
3
4
5
6
7
8
9
10
11
12
13
//*************************isFull****************************

	bool WordList::isFull()  {
	
	int WordCount = getNumWords();
      	const int MAX_WORDS = 1000;
		
		if (WordCount == MAX_WORDS)
		    return(true);		//is full
		else 
		    return(false);		//is not full

	}


In application file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
void readWords(ifstream& inf, int& countW, WordList& theList) {
               int WordNum = 0;
      	       string word;

      		while (!(theList.isFull()) && inf >> word) {

              		theList += word;
                        WordNum++;
              		theList.setNumWords(WordNum);

      		}
	
      	
	}//function delimiter 

Topic archived. No new replies allowed.