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

Consider the following class declaration when answering this question class Data

ID: 669308 • Letter: C

Question

Consider the following class declaration when answering this question

class DataBase

{

public:

       DataBase( );                       //default constructor.

       DataBase(const DataBase & Org); //copy constructor.

      ~DataBase( );                 //destructor.

       friend ostream & operator<<(ostream &, const DataBase & ); //prints all student names stored in the database.                                                                                                         

       void Insert(const string &);   //adds a student name in alphabetical order to the database.

       void Remove(const string & name);    //removes a student name from the database .

       int Find(const string & name ); //Searches the database for a student name.

                                                          // This function returns –1 if the name is not found; otherwise the location of the name.

       int Total_Letter(const char ); //Calculates and returns the number of times a specific letter appears in all the

                                                      //names stored in the database.

      bool Is_Empty( );                //Returns true if the database is empty; otherwise false.

      void Combine(const DataBase & Org );   //This function adds Org’s database to the end of the current objects database.

                                                                        //The capacity of the current object’s database is increased to the sum of Org’s and the

                                                                        //current object’s database capacities.

private:

       int capacity;      //total number of allocated student names for the database.

       int count;          //total number of student names stored in the database.

       string *S;   //the database

};

a.Implement the default constructor. Start off with an initial capacity of 10. Used the class declaration in Figure 1 above.

b.Implement the copy constructor.

c. Implement the function “Total_Letter “.

d. Implement the function “Remove”.

e. Implement the function “operator<<” as a friend function with chaining.

f. Implement the function “Combine”.

g. Implement the destructor.

h. Write a driver to test ALL the functionality of your class. If a function uses another function or if it is implied that a function is used by another function please state so in your program.

Explanation / Answer

Answer

a.Implement the default constructor.

DataBase( ){

capacity=10;

count=0;

}

b.Implement the copy constructor.

DataBase(const DataBase & Org){

x = Org.capacity;

y = Org.count;

}

c. Implement the function “Total_Letter “.

return count;

}

d. Implement the function “Remove”.

void Remove(const string & name)

{

S.erase(name) ;

{

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