C++ | Templates | Question 1

Which of the following is true about templates.
1) Template is a feature of C++ that allows us to write one code for different data types.

2) We can write one function that can be used for all data types including user defined types. Like sort(), max(), min(), ..etc.

3) We can write one class or struct that can be used for all data types including user defined types. Like Linked List, Stack, Queue ..etc.

4) Template is an example of compile time polymorphism.

(A) 1 and 2
(B) 1, 2 and 3
(C) 1, 2 and 4
(D) 1, 2, 3 and 4


Answer: (D)

Explanation: see http://en.wikipedia.org/wiki/Template_(C%2B%2B)

Quiz of this Question

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.