LearnFrenzy
Sign in Take a free test

Modern C++ Features (C++11 to C++23) · Modern C++ MCQ · Question 17

auto with brace initialisation Answer, explanation & discussion

  • MCQ
  • Hard
  • 0 comments
  • Answer explained
  • Moderated community
Question 17 Back to Exercise

What is the type of x in auto x = {1, 2, 3};?

  • A int
  • B std::vector<int>
  • C std::initializer_list<int> Correct
  • D int[3]
Correct Answer: Option C

auto x{5}; gives int, but copy-list-initialisation with = {…} deduces an initializer_list.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links