Week 3b - Template Example Code

Supports Generic Programming

Synopsis:

This session provides help with projects, then continues with templates. We will review basic ideas and then discuss code examples.

Glossary of Terms

Lecture Content:

  1. Help with Projects:

    All code will be developed using C++ and the Standard C++ Library with latest version of Visual Studio .

    Code grade sheet, Grading policy

  2. Synchronous Discussion:

    • Download, build, and run the Parser project.
    • Be prepared to describe how this code works. You will find the Parser Blog helpful.
  3. C++ Templates

    Quick overview

    Templates Presentation, pptx
    Templates are one of the terrific features of the C++ language. Almost all of the Standard Template Library (STL) is implemented with templates, and they are very useful in day-to-day programming.

    fully functional C++ Properties, courtesy of templates
    This project demonstrates how easy it is to extend the C++ language. C++ doesn't natively support properties but it's not hard to provide them.

    First template demo
    Provides a simple type to string conversion facility.

    Template Code Examples
    Basic and some more advanced template examples.

    STL Container examples
    This code contains a simple example of the new Variadic Template functionality in the "inserter" project.

    Survey of STL Container Classes
    Simple demos of almost all of the STL containers.

    STL Template-based Functors and Algorithms
    Another set of template code examples, including functors, algorithms, and several other things you need to know.

    Functor examples

    Excellent template Q&A
    This is a good place to find information to supplement class texts and notes.

  4. Lecture Take-away

    The most important things we discussed today are: Next time we will continue with class relationships. Please look at: