Quiz 3 Flashcards
Templates
- Single definition
- Permits reuse
- Compiler makes specific versions when functions are used
Function Templates
a specific behavior that can be applied to any data type
*use when applying the same function to multiple data types
Function Template Declaration
template void function(T param){}
Calling Template Declaration
- compiler substittues param types
- then compiles version of function
- multiple copies can be created
Template Functions vs Function Templates
Template functions: individually compiled functions
Function templates: entire range of related functions with same code
Class Templates
*h: template
class ClassName {}
*.cpp:template
ClassName::ClassName()
Template Classes vs Class Templates
Class templates are entire range
Template classes are individual instantiated versions
Specialization
- template provided with a set of template arguments
Class Templates and Compiling
- does not compile unused methods (could be wrong)
Overloading
multiple functions have the asme name occur in the same scope, but have DIFFERENT signatures
Overriding
(inheritance) derived class function has the same name and signature as a base class virtual function