Templates and The Standard Library
- slide 4 : 46
Example - Point<C>
We make a type parameterized Point - class
Point<C>
A type parameterized variant of class Point - point.h.
The implementation of the template class Point - point.cc.
A 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
A template class with friends