Calling Member Functions within Member Functions

So, the project I'm working on is a few thousands lines, so I'm going to use a very bare-bones example to illustrate the problem I'm having.

In my header for the DLCLRep class, I have a private "first" and a function to get at "first".

1
2
3
4
5
6
7
8
9
10
11
class DLCLNode; //Forward declaration. This class is defined elsewhere

class DLCLRep
{
  private:
    DLCLNode* first;
  public:
    DLCLNode* getFirst();
    int Count();
}


The problem arises when I try to use getFirst within another function, Count().
1
2
3
4
5
6
7
8
9
10
11
12
DLCLNode* DLCLRep::getFirst()
{
  return first;
}

...

int DLCLRep::Count()
{
  int counter = 0;
  DLCLNode* current = getFirst();
}


I keep getting hit with "error C3861: 'getFirst': identifier not found"

Any ideas?
Last edited on
You should post a code example that actually exhibits the problem you mentioned.
Also, you forgot a semicolon at the end of the DLCLRep class declaration.
Ahh, all right.

DLCLRep.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#ifndef DLCLREP_H
#define DLCLREP_H

#include "Headers\Set.h"
#include "Headers\ENode.h"

class DLCLNode;

class DLCLRep:public Set{
private:
  DLCLNode   *first;
public:
  DLCLNode* getFirst();
  void setFirst(DLCLNode* );
  void deletePtrToFirst();
	
  int countNumberBetween(string, string);
	
};

#endif 


DLCLRep.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include "Headers\DLCLRep.h"
#include "Headers\DLCLNode.h"

using namespace std;

	DLCLNode* DLCLRep::getFirst()
	{
	  return first;
	}



	/*Counts number between two elements.*/
	int countNumberBetween(string x, string y)
	{
		int count = 0;

///////////////////////////////////////////// 
DLCLNode* current = getFirst(); 
/////////////////////////////////////////////

	while (current->getPtr2Element()->Getname() != x){
		current = current->getNextNode();
	}
	
	current = current->getNextNode();
	
	while (current->getPtr2Element()->Getname() != y) {
		count++;
		current = current->getNextNode();
	}
	
	return count;
	
	}


The problem I have is with the part that I surrounded with "//".
Last edited on
Ugh. I just realized what I did wrong.

Thanks anyway. :>
Topic archived. No new replies allowed.