referencing current object from class definition

I want to call my class TLIST function "Display()" from my other functions, such as "Remove()". How do I reference the current object in this manner?

1
2
3
4
5
6
7
8
  void TLIST::Display()
{
	cout << "Print has been Invoked\n";
	for (int i = 0; i<count; i++)
	{
		cout << "DB[ " << i << " ] = " << DB[i] << endl;
	}
}



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
void TLIST::Remove(const string & key)
{
	something like, "this.Display();" 
	cout << "Remove has been invoked \n";
	cout << endl;
	
	cout << endl;
	int i = Search(key);

	if (i != -1)
	{
		for (int j = i; j<count - 1; j++) //shifting array down
		{
			DB[j] = DB[j + 1];
		}
		count--;
	}
}

Just Display() is enough. The current object is implied.

If you wish, you can use the this pointer as follows:
 
  this->Display ();

Topic archived. No new replies allowed.