Lecture overview -- Keyboard shortcut: 'u'  Previous page: Policies with Templates -- Keyboard shortcut: 'p'  Next page: Template Specialization -- 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 9 : 39
Notes about C++
Templates and The Standard Library
Example of Policies with Templates

I parameterize class Point with a 'policy for distance and comparison'

In the real world it seems more reasonable to parameterize functions - rather than classes - with policies

y:/Kurt/Files/Advanced-programming-cpp/cpp/kn/templates/functions/point-norms-and-compare/point.hThe Point class definition - a template - policy parameterized.


y:/Kurt/Files/Advanced-programming-cpp/cpp/kn/templates/functions/point-norms-and-compare/point.ccMember functions in class Point.


y:/Kurt/Files/Advanced-programming-cpp/cpp/kn/templates/functions/point-norms-and-compare/norms.ccFour different policy classes - with type parameterized static methods.


y:/Kurt/Files/Advanced-programming-cpp/cpp/kn/templates/functions/point-norms-and-compare/prog.ccA sample application.


Below we parameterize individual functions with a policy

y:/Kurt/Files/Advanced-programming-cpp/cpp/kn/templates/functions/point-norms-and-compare-3/point.hThe Point class definition - not a template in this version.


y:/Kurt/Files/Advanced-programming-cpp/cpp/kn/templates/functions/point-norms-and-compare-3/point.ccMember functions in class Point - not essential to this example.


y:/Kurt/Files/Advanced-programming-cpp/cpp/kn/templates/functions/point-norms-and-compare-3/norms.ccFour different policy classes - with type parameterized static methods.


y:/Kurt/Files/Advanced-programming-cpp/cpp/kn/templates/functions/point-norms-and-compare-3/prog.ccA sample application - together with policy parameterized functions.