πŸ“Š C++
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
πŸ’¬ Discuss
βœ… Correct Answer: (A) void myFunction(std::initializer_list<int> args) { }

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

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) { }'.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
120
Total Visits
πŸ“½οΈ
1 y ago
Published
πŸŽ–οΈ
Shiva Ram
Publisher
πŸ“ˆ
97%
Success Rate