title: Pass created object as argument, from inside that object, C++
body: <p>I am facing the following problem. I have the following classes, <code>Room</code> and <code>Reservation</code> . For <code>Reservation</code> class there is a function (<code>void Reservation :: rsrvRoomAssignment(Room* r)</code>) that assigns the <code>Room* rsrvRoom</code> member of <code>Reservation</code> class,  to a <code>Room</code> object.  I want though to call this class from inside the Room object but i have no clue on how to achieve that properly passing as argument the created object that runs the code. </p>
  
  <p>The code describes the above: </p>
  
  <p>Reservation.h</p>
  
  <pre><code>class Room;
  
  class Reservation {
  public:
      static int rsrvCode;
      string rsrvName;
      unsigned int rsrvDate;
      unsigned int rsrvNights;
      unsigned int rsrvPersons;
      Room* rsrvRoom;             // Room assigned to reservation.
      Reservation();
      ~Reservation();
      void rsrvRoomAssignment(Room*);
  
  };
  </code></pre>
  
  <p>Reservation.cpp</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "Reservation.h"
  
  using namespace std;
  
  /* 
      Constructor &amp; Destructor 
  */
  
  void Reservation :: rsrvRoomAssignment(Room* r){
      rsrvRoom=r;
  }
  </code></pre>
  
  <p>Room.h</p>
  
  <pre><code>#include "Reservation.h"
  class Room {
  public:
      static unsigned int roomNumber;
      unsigned int roomCapacity;
      Reservation* roomAvailability[30];
      double roomPrice;
      Room();
      ~Room();
      bool roomReservationAdd(Reservation*);
  };
  </code></pre>
  
  <p>Room.cpp</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include "Room.h"
  
  using namespace std;
  
  /*
      Constructor &amp; destructor
  */
  
  bool Room::roomReservationAdd(Reservation* r){
      /* some statement that returns flase */
      r-&gt;rsrvRoomAssignment(/* &amp; of created object */); // This is the problem i described.
      return 1;
  }
  </code></pre>
  
  <p>I am pretty new to OOP so there might be some more logical errors on the above snipsets, so don't be harsh :) .</p>
  
  <p>Thanks for any kind of help!</p>