Sample Question #204 (programming – C++)
Explain the following C++ concepts:
- Implicit instantiation
- Explicit instantiation
- Explicit specialization
- Partial specialization
(Comment: isn’t C++ just a nasty programming language with a nasty number of nasty details?)
Advertisements
ANSWER
These concepts relate to templates in C++.
1. The compiler uses a template to generate a function or class definition for a type based on what’s used in the template.
2. You tell the compiler exactly what type the function or class definition should be.
3. You tell the compiler to generate different function or class than based on template.
4. You partially restrict the generality of a template, providing for specific types.
Many advanced C++ books and website have specific examples.