STL and CTAD Flashcards
What does STL stand for?
Standard Template Library
What does STL do?
Allows for generic typing.
What does CTAD do?
The compiler attempts to determine the most appropriate class template for the given data
What does CTAD stand for?
Class Template Argument Deduction
What is the keyword to enable generics?
Template
What is the syntax of setting a generic with template?
template < typename template_name>
return functionName(T varname)
What is one major difference between C++ and Java generics?
C++ generics can be primitives
What is the scope of a template?
From the beginning of the function / class name, to the end of the curly brackets. Only one function.
How do you call the templated function “template < typename T>
genericsExample(T first) {…}” with double 1.0?
genericsExample<double> (1.0);
How do you declare multiple templates for one function/class?
template < typename T, typename U, …>
How do you default the typing of a template to a?
template < typename T = default_type>
What issue do templates run into when used in both .h and .cpp?
“Undefined reference to …”
What can’t templates be declared in .h and implemented in .cpp?
Because the TODO
How do you avoid template functions / classes being undefined?
Implement in the .h, or declare and implement solely in .cpp.