LearnFrenzy
Sign in Take a free test

Templates · Templates MCQ · Question 1

What problem do templates solve? Answer, explanation & discussion

  • MCQ
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 1 Back to Exercise

What is the main purpose of templates in C++?

  • A Run-time type checking
  • B Writing generic code once that works for many types, with code generated per type at compile time Correct
  • C Replacing classes
  • D Faster compilation
Correct Answer: Option B

The STL – vector, map, sort – is built entirely from templates.

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