Home > Back-end >  List of variable parameter c
List of variable parameter c

Time:04-06

Ask a question, the function of the variable parameter c and c + + is a little different
C + + can be:
Void func (... The form of) {}
-- -- -- -- -- -- -- --
According to the variable parameter macro implementation, having at least one parameter is needed to function as parameters extraction parameters on the stack (reference address), the c + + (... ) is how to achieve?


 

Void func (... ) {
//how to extract parameter?
}

Intmain () {

Func (" gnome male - ", "20, 12.00, 500);
return 0;
}



Due to the above is not clearly parameters, can only see function normal pass parameters, macro and variable parameter, but I don't know this (... ) how can extract parameter
Can't use va_list, va_start

CodePudding user response:

Grammar can be so, but no actual application scenario

CodePudding user response:

https://blog.csdn.net/qq_40946921/article/details/90648688
List of initialization using c + + 11 and 17 any c + + class, can realize the variable argument list, but I feel the effect is not big

CodePudding user response:

I use this app # CSDN# found have technical content of the blog and friends to seek common to "c + + 17 any class (universal containers), a", gathered together at https://blog.csdn.net/qq_40946921/article/details/90646022

CodePudding user response:

reference 1st floor SDGHCHJ response:
syntax can be so, but no application scenario

Cooperate with macro there is

CodePudding user response:

Struct PrintMssageException: public STD: : exception
{
The template & lt; Typename... Args>
PrintMssageException (const char * s, const Args & amp; . Rest) : exception (s) {
STD: : cerr & lt; <"\ nException rised! ";
If (s)
STD: : cout & lt; Int a [sizeof... (rest) + 1)={(STD: : cerr & lt; STD: : cerr & lt; <"\ n";
}


};
  • Related