Lecture overview -- Keyboard shortcut: 'u'  Previous page: Policies with Templates -- Keyboard shortcut: 'p'  Next page: Template Specialization -- Keyboard shortcut: 'n'  Lecture notes - all slides together  Alphabetic index  Help page about these notes  Course home    Templates and The Standard Library - slide 9 : 46

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

point.h
The Point class definition - a template - policy parameterized.
point.cc
Member functions in class Point.
norms.cc
Four different policy classes - with type parameterized static methods.
prog.cc
A sample application.

Below we parameterize individual functions with a policy

point.h
The Point class definition - not a template in this version.
point.cc
Member functions in class Point - not essential to this example.
norms.cc
Four different policy classes - with type parameterized static methods.
prog.cc
A sample application - together with policy parameterized functions.