
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
What is a template in C++?
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 Wayground
5 questions
自定義函數

Quiz
•
10th Grade - University
12 questions
Mail Merge

Quiz
•
10th Grade - University
10 questions
Herança e Polimorfismo em Java

Quiz
•
University
15 questions
Bases de Python

Quiz
•
University
14 questions
Interro 2

Quiz
•
University
14 questions
Elementos da Programação em Quiz

Quiz
•
12th Grade - University
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
20 questions
Brand Labels

Quiz
•
5th - 12th Grade
15 questions
Core 4 of Customer Service - Student Edition

Quiz
•
6th - 8th Grade
15 questions
What is Bullying?- Bullying Lesson Series 6-12

Lesson
•
11th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Information Technology (IT)
20 questions
Definite and Indefinite Articles in Spanish (Avancemos)

Quiz
•
8th Grade - University
7 questions
Force and Motion

Interactive video
•
4th Grade - University
36 questions
Unit 5 Key Terms

Quiz
•
11th Grade - University
7 questions
Figurative Language: Idioms, Similes, and Metaphors

Interactive video
•
4th Grade - University
15 questions
Properties of Equality

Quiz
•
8th Grade - University
38 questions
WH - Unit 3 Exam Review*

Quiz
•
10th Grade - University
21 questions
Advise vs. Advice

Quiz
•
6th Grade - University
12 questions
Reading a ruler!

Quiz
•
9th Grade - University