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

7. The following String class declares an operator function == , which compares

ID: 3575682 • Letter: 7

Question

7. The following String class declares an operator function ==, which compares two Strings to see if they are equal. A keyword is missing in the space underlined.

class String {

protected:

char *str;

public:

//constructors

String(); //create an empty string

String ( char *init ); //initializes str to string init

~ String (); //destructor

int length(); //returns length of this string

void prints(); //prints this string

___________ bool operator == (String &, String &);

};

What is the missing keyword?

The following code implements the destructor of String of the previous question. A keyword is missing in the space underlined.

String::~String()

{

__________ [] str;

}

What is the missing keyword?

Explanation / Answer

7. The following String class declares an operator function ==, which compares two Strings to see if they are equal. A keyword is missing in the space underlined.
class String {
protected:
char *str;
public:
//constructors
String(); //create an empty string
String ( char *init ); //initializes str to string init
~ String (); //destructor
int length(); //returns length of this string
void prints(); //prints this string
___________ bool operator == (String &, String &);
};
What is the missing keyword?
Answer: friend bool operator == (String &, String &);

The following code implements the destructor of String of the previous question. A keyword is missing in the space underlined.
String::~String()
{
__________ [] str;
}
What is the missing keyword?
Answer: delete [] str;

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