0

I have a class in C++ (VS2010).

This class has public functions, for example "ToString".

Sometimes it happens that I need to call ToString from within the class.

For example:

void::ConvertToLowerCase()
{
    wstring ws;
    ws = ToString();
    ws = lower(ws);
    m_wsText= ws
}

I would like to know if I can add an "owner" to the ToString line, for example

ws = self.ToString();

or

ws = me.ToString();

I tried all names that I could imagine, but I did not find any that would work. Having such an owner name helps me to figure out where the function resides.

tmighty
  • 10,734
  • 21
  • 104
  • 218

2 Answers2

8

In C++ you can do this via this:

ws = this->ToString(); //this is a pointer

but called in that context, this is equivalent to what you already have:

ws = ToString();
Luchian Grigore
  • 253,575
  • 64
  • 457
  • 625
3

this pointer:

ws = this->ToString();