Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ 1) Write one line of code for each line below. What is the template type in

ID: 3860947 • Letter: C

Question

C++

1) Write one line of code for each line below. What is the template type in each case?

- produce a vector to store student IDs

- produce a vector to store student names

- produce a vector to store Point2D points

- produce a set to store unique (no duplicates) student names

- produce a set to store unique (no duplicates) student IDs

- produce a map that maps student IDs to their score

- produce a map that maps student IDs to their name

- produce a map that maps student names to the name of their lab partner

Explanation / Answer

- produce a vector to store student IDs

   vector<int> data; (Template type is integer)

- produce a vector to store student names

   vector<string> data; (Template type is string)

- produce a vector to store Point2D points

   vector<Point2D> data; (Template type is Point2D)

- produce a set to store unique (no duplicates) student names

      set<string> data    (Template type is string) (return value of insert function of set can be checked for duplicates

- produce a set to store unique (no duplicates) student IDs

      set<int> data    (Template type is integer) (return value of insert function of set can be checked for duplicates
  
- produce a map that maps student IDs to their score

       map<int,int>   (Template type is integer)

- produce a map that maps student IDs to their name

    map<int,string>   (Template type is integer and string)

- produce a map that maps student names to the name of their lab partner

   map<int,string>   (Template type is string)