Can any class object be passed as test expression for any test expression such as if, while like ifstream object.
<p>In C++, can I use my objects as test expression like <code>ifstream</code> objects. If not, why?</p>

<p>e.g. </p>

<pre><code>ifstream ifs ("myfile.txt");
while( ifs ){
   //read and process data..
}
</code></pre>

<p>I have a class, which operator do I need to overload to let compiler allow my object to be passed as test expression?</p>

<p>e.g.</p>

<pre><code>MyClass obj1;
if( obj1 ){
   //do something..
}

while( obj1 ){
   //do something repeatedly..
}
</code></pre>

<p>Both should be valid expressions.</p>
