|
From: Tim S. <ti...@we...> - 2004-05-18 21:32:03
|
Hi Oroszi,
you wrote:
> I'm just courious about how can I "evaluate" an object, like fstream=20
> does it:
>=20
> ifstream infile( "C:/file.txt" );
> if ( !infile ) { /*...*/ }
>=20
> Is it done with the type conversion operator (converting to bool)?
!object you can do with overloading operators, for just checking object
I didnt figured out yet. This is a small Program which I tried and
seemed to work:
<<<<<<<<<<<<<< Schnip <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
#include <iostream>
=
=20
using namespace std;
=
=20
class test
{
private:
bool bimbes;
public:
bool operator!()
{
return bimbes;
}
test(bool a)
{
bimbes =3D a;
}
=
=20
};
=
=20
int main()
{
test blub =3D test(true);
if (!blub)
{
cout << "Cool!" << endl;
}
return 0;
}
>>>>>>>>>>>> Schnapp >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
but if you want to know how it works exactly, just look at the source of
fstream.
so long
Tim
--=20
http://we-are-teh-b.org/~tim/borg.key
http://learn.to/quote
|