title: C++ classes: read value behave as different types
body: <p>I want to create a class similar to this:</p>
  
  <pre><code>class MyTime {
  public:
      int seconds;
      int useconds;
  
      /*** functions ***/
  }
  </code></pre>
  
  <p>but which has the following behavior:</p>
  
  <pre><code>MyTime now;
  double current_time = now; // returns double representing seconds
  </code></pre>
  
  <p>Is there a way to do this without have to define an <code>asDoubleSeconds()</code> function? Can I change the behavior by overloading the assignment operator somehow?</p>
  
  <p>If not, is there a way to do something like this:</p>
  
  <pre><code>double current_time = double(now);
  </code></pre>