tricky code
consider this one its one good tricky code i encountered :
#include <iostream>
using namespace std;
int main()
{
cout << cout;
return 0;
}
any guesses what would be the output ?
It will output the address of the << operator of cout. (I think :0) )
actually it would output the address of object cout of the class ostream
I don't think it is the address of the cout object...
It is implementation defined.
It calls basic_ios::operator void*(), which is the function that
gets called when you do something like
1 2 3
|
if( cin ) {
// do stuff
}
| |
the function has to return non-zero if the stream is OK or zero otherwise.
Topic archived. No new replies allowed.