Please complete in C++ not java! Include output screenshot as well! Part 1: Temp
ID: 3833100 • Letter: P
Question
Please complete in C++ not java! Include output screenshot as well!
Part 1: Template The syntax for class tempi is basical he sam hat for functio templates nt will be plared before the templ The type paramater T he d ke any uther ty Pe. Hi template eclass T class Aar publc: prtrate. T second, yar of of tyve Once the clays te decla objects of this d he dec specfr what type T. For exampl declares the object score tc record a pair of integ poi char-seat; dederes the cbiect seetto record pair of dharacters The two objects can be used like ot objects. or exampl fnr the you Here are the definitions for the member functions set cement and the constructor Far with wo arguments second value; Megui puir posit empty bady befor ge resolut Important note operator late may be used the type for a function parametor: returns the sum of the two Integers In the emir. You can use a clast template whthin a function Type Definitions u: argument tu the following erample: The special hen be other yects or to spccfr the type of a for new clas lized class tem name, Parwints. The syntax for such a defined type name Is: he type be used to declare obect: of type Ruvont The type name yargfint can also be used to specify the type of a fommal parameter. for the ber funct get element he cl ate Haw and the constructor with no arg ent. Add to function caled Then w program that uses the lass to read a pair ofExplanation / Answer
class template
<utility>
std::pair
template <class T1, class T2> struct pair;
Pair of values
This class couples together a pair of values, which may be of different types (T1 and T2). The individual values can be accessed through its public members first and second.
Pairs are a particular case of tuple.
Template parameters
T1
Type of member first, aliased as first_type.
T2
Type of member second, aliased as second_type.
Member types
member type
definition
notes
first_type
The first template parameter (T1)
Type of member first.
second_type
The second template parameter (T2)
Type of member second.
Member variables
member variable
definition
first
The first value in the pair
second
The second value in the pair
Member functions
(constructor)
Construct pair (public member function )
pair::operator=
Assign contents (public member function )
pair::swap
Swap contents (public member function )
Non-member function overloads
relational operators (pair)
Relational operators for pair (function template )
swap (pair)
Exchanges the contents of two pairs (function template )
get (pair)
Get element (tuple interface) (function template )
Non-member class specializations
tuple_element<pair>
Tuple element type for pair (class template specialization )
tuple_size<pair>
Tuple traits for pair (class template specialization )
member type
definition
notes
first_type
The first template parameter (T1)
Type of member first.
second_type
The second template parameter (T2)
Type of member second.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.