Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need to write a program that creates a collection of back account numbers and persons associated with their number. Use the std::map container from

I need to write a program that creates a collection of back account numbers and persons associated with their number. Use the std::map container from the Standard Template Library with these specifics.

You will also need to create a person class. It should have 3 data members:

unsigned age;

std::string ssn;

std::string name;

It will only need two member functions:

A constructor (that takes 3 parameters),

An operatoroverload (see below for why this is required)

You may also add a destructor with a printout stating it ran. That may be useful to you during debug and you may include that output in your submission if you wish

For your main program / driver for this assignment, create a file called bankAccountMap.cpp

Inside of it:

// Create 10 person objects using your newly created person class

person person9 (40,"123-45-6780","Austin");

...

// Create a std::map called bankAccountMap

...

// Insert into the bank account map using this code snippet (again see my example, and look at the whole example not just the beginning):

bankAccountMap.insert ( ... )

// The previous line uses extended initializer lists, and must be compiled with -std=c++0x on my Mac and Windows Ubuntu

// but it has not been necessary on Elvis, at least in my testing.

You will also need to print out your entire map using iterators (again see my example). However to print your person class you will need to overload the stream insertion operator

For your operator

Person name: Brendan, age: 35, SSN: 123-45-6788

That is accomplished by using

yadayadafreebeer

See the boxClass assignment for hints and examples

This operator overload is required to use the iterator of your bankAccountMap while printing (again using my example). If you don't overload operator

-bash-4.4$ g++ personClass.cpp bankAccountMap.cpp

bankAccountMap.cpp: In function int main(int, char**):

bankAccountMap.cpp:22:34: error: no match for operator and

person)

std::cout first second

The output must match the following imageimage text in transcribed

-bash-4.4$ ./bankAccountMap Size of bankAccountMap: 10 Iterate over bankAccountMap from beginning to end 1230Person name: Jon, age: 34, SSN: 123-45-6789 1231 1232 1233 1234 1235 1236 1237 1238 1239 Person name: Brendan, age: 35, SSN: 123-45-6788 Person name: David, age: 36, SSN: 123-45-6787 Person name: Alex, age: 37, SSN: 123-45-6786 Person name: Anwar, age: 38, SSN: 123-45-6785 Person name: Max, age: 39, SSN: 123-45-6784 Person nameIan, age: 40, SSN: 123-45-6783 Person name: Gabriella, age: 40, SSN: 123-45-6782 Person name: Sarah, age: 40, SSN: 123-45-6781 Person name: Austin, age: 40, SSN: 123-45-6780 After deleting a specific key/value pair, print again 1230 1231 1232 1233 1234 1236 1237 1238 1239 Person name: Jon, age: 34, SSN: 123-45-6789 Person name: Brendan, age: 35, SSN 123-45-6788 Person name: David, age: 36, SSN: 123-45-6787 Person name: Alex, age: 37, SSN: 123-45-6786 Person name:Anwar, age: 38, SSN: 123-45-6785 Person name: Ian, age: 40, SSN: 123-45-6783 Person name: Gabriella, age: 40, SSN: 123-45-6782 Person name: Sarah, age: 40, SSN: 123-45-6781 Person name: Austin, age: 40, SSN: 123-45-6780 After deleting the key/value pair at the end of the map, print again 1230 Person name: Jon, age: 34, SSN: 123-45-6789 1231 1232 1233 1234 1236 1237 1238 Person name: Brendan, age: 35, SSN: 123-45-6788 Person name: David, age: 36, SSN: 123-45-6787 Person name: Alex, age: 37, SSN: 123-45-6786 Person name: Anwar, age: 38, SSN: 123-45-6785 Person name: Ian, age: 40, SSN: 123-45-6783 Person name: Gabriella, age: 40, SSN: 123-45-6782 Person name: Sarah, age: 40, SSN: 123-45-6781 bash-4.4$

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions