Chapter 16

 < Day Day Up > 



Chapter 15

  1. In your own words explain what static polymorphism is and how it is achieved in C++ using function and class templates.

    Static polymorphism happens at compile time when a parameterized function, structure or class is used to specify a new function or class type.

  2. In your own words give a definition of a template.

    A template is a generic specification of a function, structure, or class that can be used to create a specific function, structure, or class type.

  3. How are function templates related to overloaded function?

    Function templates can often be used in place of function overloading because one generic function can be declared and defined to work on multiple parameter data types.

  4. How are places reserved in source code for type substitution?

    By using type placeholders.

  5. How many type placeholders can a function or class template declare?

    As many as are required.

  6. If the number of type placeholders declared in a function template is greater than the number of function parameters, how can the type of extra placeholders be specified when the function is called?

    Using the template specialization syntax.

  7. Why is it a good idea to group the declaration and definition of a class or function template in one header file?

    To ensure compatibility.

  8. Is it necessary to group the declaration and definition of a class or function template in one header file?

    It depends on the compiler.

  9. What is the purpose of an STL container adapter?

    STL container adapters use STL containers to implement their functionality.

  10. What are iterators and how are they related to pointers? What is the purpose of an iterator? What benefits do you gain from using iterators to manipulate container elements vs. other iterative methods.

    Iterators provide a uniform way to manipulate elements in a container component regardless of the container type.



 < Day Day Up > 



C++ for Artists. The Art, Philosophy, and Science of Object-Oriented Programming
C++ For Artists: The Art, Philosophy, And Science Of Object-Oriented Programming
ISBN: 1932504028
EAN: 2147483647
Year: 2003
Pages: 340
Authors: Rick Miller

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net