The original fucntion returns nothing (void). The macro helps after calling
the function also to get the result value of counter.
Thanks Vladimir,
I do not understand how this statement works,
(Foo( &counter ), counter);
I have tested that the simple statement (without comment) also works. What
is the benefit and function to add , and counter in macro definition?
// #define GETFOO Foo((&counter), counter)
#define GETFOO Foo(&counter)
regards,
George
"Vladimir Grigoriev" wrote:
In the function Foo() the statement return is obsolete. So the valid code
of
the function looks like
void Foo (int* input)
{
*input = 100;
}
The macro GETFOO uses operator ',' (comma). For the comma operator the
last
value in the list is the value of the operator in whole.
for example, for
int i = ( 2, 3);
i will be set to 3.
It is better to rewrite the function Foo() as
int Foo( int & input )
{
input = 100;
return ( input );
}
Vladimir Grigoriev
"George" <George@discussions.microsoft.com> wrote in message
news:AD5B3494-BD1F-4520-AF76-9F708CE66E36@microsoft.com...
Hello everyone,
I can not understand how the following code works and assign 100 to
counter
variable?
[Code]
void Foo (int* input)
{
*input = 100;
return;
}
#define GETFOO (Foo( &counter ), counter)
int counter;
int main()
{
GETFOO;
return 0;
}
[/Code]
thanks in advance,
George