Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

When using static arrays in cpp , the size that needs to be allocated must be known at COMPILE TIME, so we must set some

When using static arrays in cpp, the size that needs to be allocated must be known at COMPILE
TIME, so we must set some kind of max size if we are using static arrays. This is why in most
cases, std::vector will be more useful as it resizes itself. In the next lab, we will learn how we can
resize dynamically allocated arrays but know that a static array like this cannot be deleted and
resized later.
Note that the Contact and ContactBook class must be made independently of each other since we
will be adding contacts directly to the book by passing an actual Contact object to it. This means
that the Contact class can NOT be made inside of the ContactBook class.
3.2 Methods in Contact class
Parameterized Constructor passing two string parameters (Required)
getName, which returns the name of the contact (suggested)
getNumber, which returns the number of the contact (suggested)
Display, which will not return anything, and just display the contact info in the following way:
Sam, 7654356237(suggested)
3.3 Required methods: ContactBook class
Default Constructor
Find - Takes in a string that can either be a phone number or a name and returns the found contact
as a pointer. Returns a nullptr if a given string is not a name or a number in the contact system.
Add - Takes in a contact object and stores its memory address in the furthest-most empty position
in the array. The current order of contacts in the array must be preserved. (Note: passing by value
will result in a garbage pointer). It returns nothing. Also know that there will never be a
test case that tries to add a Contact that already exists in the ContactBook, and this
applies for all the addition functions, even the operators.
AddContacts - Takes in a vector of contact pointers, and stores all of it's values in the class's array,
in the same order that they were in the vector. It returns nothing.
Remove - Takes in a contact object, and removes the associated contact from the array. (See the
note in Add) The rest of the contacts should stay in the same order in the array, which may mean
you would have to shift all the pointers ahead in the array back one place. It returns nothing.
Display - Displays each contact in the contact book, in the order that they are stored in the array.
For example like this:
Roland, 456-789-0123
Andres, 987-654-3210
George, 234-567-8901
Lily, 345-678-9012
Justin, 123-456-7890
Alphabetize - sorts the array in alphabetical order based on contact name. Note that in this special
case, Albert would come before Alberta. This should be the only function that can alter the order
that the contacts are stored in the array.
the following operators:
@,+= Contact - Adds a single contact to a ContactBook object
@,+= ContactBook - Adds all contacts from the passed in ContactBook to this object. Adding
them to the back in the order they are in the other ContactBook's array.
@+ ContactBook - Adds two contact books together and returns the resulting ContactBook.
@-= Contact - Removes the Contact that matches the passed-in Contact.
@-= ContactBook - Removes all contacts from a passed in ContactBook from this object
image text in transcribed

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

Distinguish between poor and good positive and neutral messages.

Answered: 1 week ago

Question

Describe the four specific guidelines for using the direct plan.

Answered: 1 week ago