LearnFrenzy
Sign in Take a free test

Templates · Templates MCQ · Question 6

What can a non-type template parameter be? Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 6 Back to Exercise

In std::array<int, 5>, what kind of template argument is 5?

  • A A type argument
  • B A non-type argument – a compile-time constant value Correct
  • C A default argument
  • D A run-time variable
Correct Answer: Option B

It must be known at compile time: int n = 5; std::array<int, n> does not compile.

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