 <p>Here I think a <a href="http://publib.boulder.ibm.com/infocenter/cellcomp/v101v121/index.jsp?topic=/com.ibm.xlcpp101.cell.doc/language_ref/cast_operator.html" rel="nofollow">user-defined conversion <code>operator</code></a> would be more appropriate.</p> <pre><code>class rational { public: rational( int iNum, int iDen ) : num( iNum ), den( iDen ) {} // ... operator double() { return (double)num / (double)den; } private: int num; int den; }; int main() { rational r( 1, 2 ); double n = r; std::cout &lt;&lt; r &lt;&lt; std::endl; // output 0.5 return 0; } </code></pre> <p>Here is a little live example to illustrate this : <a href="http://ideone.com/I0Oj66" rel="nofollow">http://ideone.com/I0Oj66</a></p> <hr> <p>About the <em>copy assignment <code>operator=</code></em> :</p> <blockquote> <p>A copy assignment operator of class <code>T</code> is a non-template non-static member function with the name <code>operator=</code> that takes exactly one parameter of type <code>T</code>.</p> </blockquote> <p>The <a href="http://en.cppreference.com/w/cpp/language/as_operator" rel="nofollow"><code>operator=</code></a> is used to change an existing object.</p> <p>You can use it for example to copy the state of another object :</p> <pre><code>rational &amp;operator=( const rational &amp;rhs ) { num = rhs.num; den = rhs.den; return *this; } </code></pre>