Original Post
Can someone explain to be why...
void testfunc (const int a, ...)
{
va_list Params;
va_start (Params, a);
cout << va_arg (Params, int);
va_end (Params);
}
void main()
{
testfunc (5, 6);
}
This correctly outputs '6', whereas this:
void testfunc (const int &a, ...)
{
va_list Params;
va_start (Params, a);
cout << va_arg (Params, int);
va_end (Params);
}
void main()
{
testfunc (5, 6);
}
Outputs '1245120'... (I don't think there is any signficance to this value)
This different is that in one 'a' is passed by value, and in the other it's passed by reference. Lets say I NEED to pass this by reference (because in my real program it's a std::string), how can I fix this so that it works?
[edited by - Barguast on April 23, 2004 10:06:37 AM]