S

Shiva Ram • 30.44K Points
Instructor I

Q. Which of the following is the correct way to define a function with a variable number of arguments using initializer_list in C++?

  • (A) void myFunction(std::initializer_list<int> args) { }
  • (B) void myFunction(int... args) { }
  • (C) Both A and B
  • (D) None of the above
  • Correct Answer - Option(A)
  • Views: 59
  • Filed under category C++

Explanation by: Shiva Ram
The correct way to define a function with a variable number of arguments using initializer_list is 'void myFunction(std::initializer_list<int> args) { }'.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.


Question analytics