Menu

[Solved]Description Purpose Challenge Define Basic Class Implements Copy Constructor Requirements Q37298908

Description

The purpose of this challenge is to define a basic class thatimplements a copy constructor.

Requirements

  1. Define a class called Contact as belowclass Contact{ private: string first; string last ; string * aliases; public: // default constructor Contact() { aliases = new string[3]; } // copy constructor Contact(const Contact &contact) { // create the array // perform deep copy of data members } // you will need to complete the definitions for these string get_fullname(); void set_first(string f); void set_last(string l); // returns a comma-separated list of aliases string get_aliases(); // sets one element of aliases at position i void set_alias(string alias, int i); };
  2. Write a default constructor that will create a new array ofstrings that will hold 3 elements (see above)
  3. Write a copy constructor that will perform a deep copy of theobject itself (its data members and its array data)
  4. Write a getter function that will return the person’s full nameas a concatenation of first and last.
  5. Complete the other public functions whose prototypes are givenin the class definition above
  6. In main, instantiate an object, person1
  7. Ask the user to enter first name, last name and 3 aliases intoperson1
  8. Instantiate another object, person2. Using objectinitialization, assign person1 to person2.
  9. None of the functions in the class should cout orcin. Do not ask for user input within the class (Usingcout’s for debugging is ok)
  10. Ask the user to enter 3 aliases into person2. Youdon’t have to ask for first name and last name forperson2.
  11. Display person1’s and person2’s full name andaliases. (Notice that both objects have the same first and lastname, but different aliases)
  12. Create as many supporting private/public functions as you thinkyou might need

Sample main()

// class definition hereint main(){ Contact person1; string first; person1.set_first(first); return 0;}

Sample Interaction

First name: MichaelLast Name: JordanAlias 1: MJAlias 2: AirJordanAlias 3: TheGOATAlias 1: GreatestAlias 2: MoneyAlias 3: Number23Michael Jordan : MJ, AirJordan, TheGOATMichael Jordan : Greatest, Money, Number23

Expert Answer


Answer to Description The purpose of this challenge is to define a basic class that implements a copy constructor. Requirements De… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *