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;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.