Changes

Jump to: navigation, search

C/C++ FAQ

635 bytes added, 01:32, 18 September 2012
C/C++ FAQ
'''''Submitted by:''''' ''Gideon Thomas and Marie Karimizadeh''<br>
----
<br>
'''Q:''' When we define a function-like macro, does the compiler ignore or take into consideration the spaces in between the parentheses?<br>
For example:
<source lang="cpp">
#define F( x ) ((x) + (x))
int main()
{
int a = 5;
cout << F( a );
return 0;
}
</source>
Which one of the following will the cout statement change to and why:
:# cout << ((a) + (a));
:# cout << x ) ((x) + (x)) a);
Note: in the second case, F( is considered the symbolic constant and is replaces by the rest of the string i.e. x ) ((x) + (x)) wherever it occurs.
 
 
'''''Submitted by:''''' ''Gideon Thomas and Marie Karimizadeh''<br>
----
<br>

Navigation menu