Describe the syntax we use for a class template.
Chapter3: Using Methods, Classes, And Objects
Section: Chapter Questions
Problem 16RQ
Related questions
Question
Describe the syntax we use for a class template.
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
Step 1
Class template:
A class template creates basic outline for a class. The members of that class use arguments of the type template argument. The syntax statement for class template declaration is as below:
Step 2
template <class template_name> class class_name {
class_namemember_name( template_nameargument_name)
};
Class template specialization is the instant of a function created by the compiler from the template for a specific set of arguments passed to the object. The syntax statements are specialized as in the example below:
- Consider a class template display with type parameter class_name called with double arguments.
- The compiler then detects a display object invocation in the code.
- Type parameter template_name is substituted by double throughout the definition.
- The class template specialization created is display< double> instead of template type display <template_name>.
Step by step
Solved in 3 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT