Connecting Tech Pros Worldwide Forums | Help | Site Map

A Qustion about iostream

want.to.be.professer
Guest
 
Posts: n/a
#1: Aug 29 '08
Yesterday, my friend ask me a question about iostream.I know the
result ,but can't explain.The program is below:

---------------------------------------------------------------------------------------------------------------------------------------------------
#include <iostream>

using namespace std;

int fun( int x )
{
cout << "____in fun()____" << endl;
return x;
}

int main()
{
int x = 9;
cout << "b = " << x << fun2( 2 ) << "ads" << endl;
return 0;
}

-------------------------------------------------------------------------------------------------------------------------------------------------------
The program run as below:

1.function "fun()"
2.operator << ( basic_iostream<char, _Traits>& _Ostr, const char*
_Val )
( _Val== "b = " )
3. a member function : operator<<(int _Val)
( _Val == 9 )
4. a member function : operator << ( int _Val )
( _Val == 2 )
5. operator << ( basic_iostream<char, _Traits>& _Ostr, const char*
_Val )
( _Val== "ads" )

But why it run like this? I can't explain.So I put in here to wait a
answer.

Closed Thread