0

I am calling a function firstFunction and passing it variadic arguments (const char* fmt, ...) : I would like to execute some calculations here and then pass the parameters to another function, secondFunction that has (const char* fmt, ...) as input arguments.

void firstFunction(const char* fmt, ...)
{
 //does some pre-condition stuff

//calls secondFunction (how?)
}

void secondFunction(const char* fmt, ...)
{
//prints the input parameters in a va_list using vsnprtinf
}     

What is the C++ syntax to pass variadic arguments from a function to another?

EDIT 1: I can't use templates, since I would like these functions to be a definition of pure virtual functions declaration.

EagleOne
  • 541
  • 1
  • 10
  • 28

1 Answers1

4

That's a variadic paramater, not a parameter pack. In c++ you would write:

    template <class... Args>
    void firstFunction(const char* fmt, Args&&... a) {
        secondFunction(fmt, std::forward<Args>(a)...);
    }
christianO
  • 167
  • 11