Returning *this, attempting cascading, and not returning a reference
<p>I have a question that is similar to the question that was asked here: <a href="http://stackoverflow.com/questions/7249903/how-does-this-cascading-work">How does &quot;this&quot; cascading work?</a></p>

<p>Suppose I have the following code:</p>

<pre><code>#include &lt;iostream&gt;
using namespace std;

class Time
  {
  public:
     Time( int = 0, int = 0, int = 0 );
     Time setHour( int );
     Time setMinute( int );
     void print( void );

  private:
     int hour;
     int minute;
  };

  Time::Time(int hr, int mn, int sc)
  {
     hour = hr;
     minute = mn;
  }

  void Time::print( void )
  {
     cout &lt;&lt; "hour = " &lt;&lt; hour &lt;&lt; endl;
     cout &lt;&lt; "minute = " &lt;&lt; minute &lt;&lt; endl;
  }

  Time Time::setHour( int h )
  {
     hour = ( h &gt;= 0 &amp;&amp; h &lt; 24 ) ? h : 0;
     return *this;
  }


  Time Time::setMinute( int m )
  {
     minute = ( m &gt;= 0 &amp;&amp; m &lt; 60 ) ? m : 0;
     return *this;
  }

int main()
{
   cout &lt;&lt; "Hello, world!" &lt;&lt; endl;
   Time t;
   t.setHour( 10 ).setMinute( 25 );
   t.print();
}
</code></pre>

<p>Then, it is clear that the function setMinute( 25 ) is not running on the Time object t. Note that the functions setHour and setMinute do not return references to Time objects. </p>

<p>What is happening after t.setHour( 10 ) executes? Does the function setHour somehow return a "copy" of the object t, and setMinute( 25 ) is running on the copy? I have compiled the program with -Wall and no errors or warnings are returned.</p>

<p>Thanks for your assistance.</p>
