Lecture overview -- Keyboard shortcut: 'u'  Previous page: Templates versus generics in Java, C# and C++ -- Keyboard shortcut: 'p'  Next page: Class templates in C++ -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Lecture 5 - Page 4 : 39
Notes about C++
Templates and The Standard Library
Example - Point<C>

We make a type parameterized Point - class Point<C>

y:/Kurt/Files/Advanced-programming-cpp/cpp/kn/templates/vers2/point.hA type parameterized variant of class Point - point.h.


y:/Kurt/Files/Advanced-programming-cpp/cpp/kn/templates/vers2/point.ccThe implementation of the template class Point - point.cc.


y:/Kurt/Files/Advanced-programming-cpp/cpp/kn/templates/vers2/prog.ccA program that illustrate template instantiation.


  • Lessons learned

    • The definition of member functions in the template class becomes more complex

      • See the file point.cc

    • Template instantiation first occurs when Point<int> and Point<double> is encoutered

      • For this reason, point.cc must be included in prog.cc instead of (as usual) point.h

Go to exerciseA template class with friends