#ifndef _PAIR_H_ #define _PAIR_H_ // Class template definition has the template // parameter ("Thing") in scope throughout template class Pair { public: Pair() { }; // default constructor still initializes data members Thing get_first() const { return first_; } // inline definition Thing get_second() const { return second_; } // inline definition void set_first(Thing ©me); void set_second(Thing ©me); void Swap(); private: Thing first_, second_; }; // Nonmember function declaration -- not needed for // compilation since Pair.cc is included in this header // file, but good to make visible to customer. template ostream &operator<<(ostream &out, const Pair &p); // The compiler must see the definition for any template that is // used. That means customers of Pair.h need to be // shown the definition of class Pair; one way to do this is to // include the .cc file associated with the .h file right in // the header, as follows. This is the "inclusion compilation // model." #include "Pair.cc" #endif // _PAIR_H_