title: Create a pointer inside a constructor to point to the instance of the class in C++
body: <p>I'm a bit confused with these C++ pointers and I would like to know if it's possible to create a pointer inside a constructor that will point to the instance of the class (something on the lines of the following). </p>
  
  <pre><code>class Room{
  public:  
      Room();  
      ~Room();  
  private:  
      Room* ptrToSelf;  
  };  
  
  Room::Room(){  
      ptrToSelf = &amp;(what should I write in here to have the pointer point to it)  
  }
  </code></pre>
  
  <p>I know this might sound crazy (newbie here), but I just wanted to know if it is possible. Could someone please explain this to me.<br>
  Many thanks  </p>
  
  <p>Edit:<br>
  Thank you everyone for answering me so fast. I was asking because I wanted to use a public <code>Room*::getPointer();</code> method to return the pointer for the class. I have a character that moves from room to room and I'm using pointers to achieve this. I'm getting the input from the user in form of string and I can't pass that string to the function to <code>character.moveTo(const Room*)</code> method I created. I need a way to "convert" the string into a pointer for the class so that I could pass the pointer to the method.  </p>
  
  <p>Edit:<br>
  I was thinking of implementing a method that will return the pointer for the object based on a string type parameter:</p>
  
  <pre><code>Room::Room* getPointer(const string &amp;nameOfRoom){  
      //I can't use this return statement as the following error  
      //Error: 'this' may only be used inside a nonstatic member function  
      return this; 
  </code></pre>
  
  <p>Edit (hopefully last one):<br>
  Is this returning what I'm looking for?  </p>
  
  <pre><code>Room::Room* getPointer(const string &amp;nameOfRoom){    
      return &amp;Room();  
  }
  </code></pre>
  
  <p>or it's returning the address of a new Room?<br>
  Thank you</p>