It's not very clear what this code should do. But for starters:
type va_arg(va_list ap, type);
Passing Args.wins first argument Args.wins incorrect. Further, if this is corrected, then g ++ produces the following:
main.cpp: In function 'int Result(float, Hero, ...)': main.cpp:14:29: warning: 'float' is promoted to 'double' when passed through '...' [enabled by default] wins = va_arg(list, float); ^ main.cpp:14:29: note: (so you should pass 'double' not 'float' to 'va_arg') main.cpp:14:29: note: if this code is reached, the program will abort
But this is minor compared to the main mistake. It is impossible to transfer to processing va_* structure, not to mention the class. And that's why:
struct Hero { char c; short s; double d; }; printf("%lu, %lu\n", sizeof(Hero), sizeof(char)+sizeof(short)+sizeof(double));
In my case, 16, 11 will be displayed, but not the fact that it will be so in yours :) va_* oriented on the size of the types, but in the case of structures, they cannot do this because of the alignment of the fields.
type va_arg(va_list ap, type);are you wrong? - PinkTux