Draw a sketch of a Pair containing the elements "CPSC" and 131. Replace this with your sketch.
Opera
-
- Site Admin
- Posts: 899559
- Joined: Mon Aug 02, 2021 8:13 am
Draw a sketch of a Pair containing the elements "CPSC" and 131. Replace this with your sketch.
Opera
Operations Your Pair class will need to implement the following public API. Class Template template <class Ti, class T2> class Pair; Construction and Destruction Pair(const T1& first, const T2& second): Constructor. Pair(const Pair<T1, T2>& other): Copy constructor. Pair& operator=(const Pair<T1, T2>& other): Copy assignment constructor Pair(): Destructor Observers T1 first() const: Return a copy of the first of the objects. T2 second() const: Return a copy of the second of the objects. Modifiers void set_first(const T1& first): Set the first object of the class. Like all of the data structures in this course, in practice we should not be designing and implementing, we should be reusing (here, std::pair). In practice, for each of these use cases, it might be better to create a specialized class rather than using a generic Pair class. void set_second(const T2& second): Set the second object of the class. void swap(Pair<T1, T2>& other): (optional to implement) Swap this pair with other.