What is a template in C++?

C++ Templates Quiz

Quiz
•
Information Technology (IT)
•
University
•
Hard
Yasmin Kandil
Used 10+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
A predefined function
A blueprint for creating functions or classes
A type of variable
A keyword in C++
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is a correct way to define a function template?
`template function<int> void func() {}`
`template <typename T> void func() {}`
`function template<T> void func() {}`
`template <T> void func() {}`
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the primary benefit of using templates in C++?
Improved performance
Code reuse and type safety
Simplicity of syntax
Increased memory usage
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following statements about class templates is true?
Class templates cannot have member functions.
Class templates are not type safe.
Class templates can be instantiated with different types.
Class templates require a return type.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How do you instantiate a template class with the type `int`?
`MyClass<int> obj;`
`MyClass obj<int>;`
`MyClass obj(int);`
`MyClass<int> obj();`
6.
MULTIPLE SELECT QUESTION
45 sec • 1 pt
What keyword is used to define a template parameter that can accept any type?
`var`
`template`
`typename`
`class`
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is an example of a template specialization?
`MyClass<int> obj();`
`template<> void func<int>() {}`
`template<type T> void func() {}`
`void func() {}`
Create a free account and access millions of resources
Similar Resources on Quizizz
10 questions
Abstracciones procedimentales

Quiz
•
University
10 questions
Java Quiz (Basics)

Quiz
•
University
13 questions
Session 15 + 16 : Function

Quiz
•
University
10 questions
PRF192

Quiz
•
University
10 questions
Code Twisters Round 1 Demo

Quiz
•
University
15 questions
Punteros y Memoria Dinamica

Quiz
•
University
10 questions
Quiz Meet 1 Mini SC Programing

Quiz
•
University
10 questions
Teste de revisão - Liguagem C

Quiz
•
University
Popular Resources on Quizizz
15 questions
Character Analysis

Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing

Quiz
•
9th - 12th Grade
10 questions
American Flag

Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension

Quiz
•
5th Grade
30 questions
Linear Inequalities

Quiz
•
9th - 12th Grade
20 questions
Types of Credit

Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25

Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers

Quiz
•
6th - 8th Grade