home *** CD-ROM | disk | FTP | other *** search
- // Templts.cpp
-
- #include <iostream.h>
- #include "templts.h"
- #include "contents.h"
-
- // Constructor
- template <class T>
- RailroadCar<T>::RailroadCar(int NewCarNumber,
- T& NewContents)
- {
- CarNumber = NewCarNumber;
- pContents = &NewContents;
- }
-
- // Destructor
- template <class T>
- RailroadCar<T>::~RailroadCar()
- {
- Unload();
- }
-
- // Public member functions
- template <class T>
- void RailroadCar<T>::ShowContents()
- {
- cout << "Railroad car #" << CarNumber;
- cout << " is filled with " << pContents->isA();
- cout << "s\n";
- }
-
- template <class T>
- T* RailroadCar<T>::Unload()
- {
- T* temp = pContents;
- pContents = NULL;
- return temp;
- }
-
- // Force instantiation of templates
- template RailroadCar<Cow>;
- template RailroadCar<Passenger>;
-