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

In mathematics a mapping is a function that takes items from one set and transfo

ID: 3840411 • Letter: I

Question

In mathematics a mapping is a function that takes items from one set and transforms it into an item from a second set. Most of the time these items are numbers and the sets are R, C, I, etc. But in higher mathematics they can end up being weirder things...

Anyway, computer scientists find that this concept of the map is really useful in modeling real-world situations. What is a program, after all, but a map from inputs to outputs?

What we normally do is create two parallel arrays and have items from each set in aligned positions in each of the two arrays. The main operations are create a new mapping (two new items are entered into the arrays which are to be associated together) and retrieve one value of an associated pair given the other (normally this look-up is only done in one direction; you don't have to provide the ability to search either array and retrieve the other ones value).

Since we apply maps in many different situations, it is useful to have a templated map so that the original and ending items can be of any type we choose (short, double, String, Date, char*, Point*, etc.).

You, of course, are to create such a class. You can use a pair of static arrays for your mapping, but they must be templated so that the programmer can map different types of information.

Since your map is static, you'll also provide a full method (in addition to your insertion and lookup methods).

Finally, maps aren't typically read in, but are often printed out. Normal format is:

Show how useful your template map class is by creating maps:

-- all in one test application. (Maybe a templated function would help relieve your test application tedium, too?!

Thought Provoking Questions

What operators might you overload for the map operations: enter pair, lookup second value of pair, map full?

From To short integers doubles String class objects (static) Point class objects characters pointers to Point class objects (each allocated on the heap)

Explanation / Answer

All the below are templated with

Function template i..e ()

1. pair

pair is actually a struct i..e structure holding template of 2 types of class an () is overloaded as function to make the pair

2. second

Overload is the Template class

3. map full

Here overloaded in ++ operator . This lets one size of the Map

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote