Chapter 32 Flashcards
Can a generic program abstraction (function, class) can be parameterized with a type
Yes
Can there be any type of data in generic program abstraction
Yes
What are the advantages of generic programming
- Reusability
- Writability
- Maintainability
What are templates
Templates are the foundation of generic programming, which involves writing code in a way that is independent of any particular type. A template is a blueprint for creating a generic class or a function.
What are 2 kinds of templates
- Function templates
- Class templates
What compiler do with templates
Compiler generates different type-specific copies from a single template
Can a function template be parameterized to operate on different types of data
Yes
Is it possible a function template may not have any parameter
Yes
Is it possible a template may not handle all types successfully
Yes