ANSWER BANK Move the necessanry blocks over into the response area: delete () temp; char" temp- this->value; strcat(this->value, rightObj.c_str()); return this; this->max_length - newlen; H// Concatenation assignment operator for StringVar class. i if (this =- &rightobj) return *this; I #include strcpy(this->value, temp); I StringVar& StringVar::operator - (const StringVar& rightobj) { if (this->max_length < newlen) { i this->value[@] ▪ '\®*; I #include "StringVar.h" this->value - new char[this->max_length+1]; int newlen = length()+right0bj.length(); this->value nullptr;

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter3: Using Methods, Classes, And Objects
Section: Chapter Questions
Problem 1GZ
icon
Related questions
Question

c++

Assume that StringVar.h has the following declaration:
#include siostream>
class stringvar {
public:
stringvar() : max_length(28) {
value = new char[max_length+1];
value[0] = '\e";
// Default constructor size is 20
stringvar(int size);
// Takes an int for size
stringvar(const char cstr[]);
// Takes a c-string and copies it
stringvar(const stringvar& strobj);
// Copy Constructor
-stringvar();
// Destructor
int size() const { return max_length; }
// Access capacity
const char* c_str() const { return value; } // Access value
int length() const { return strlen(value); } // Access length
stringvar& operator= (const stringvar& rightobj);
stringvar& operator+= (const stringvar& rightobj);
std::istream& operator>> (std::istream& in, stringvar& strvar);
std::ostreame operator<« (std::ostream& out, const stringvar& strvar);
private:
int max_length;
char value;
};
Transcribed Image Text:Assume that StringVar.h has the following declaration: #include siostream> class stringvar { public: stringvar() : max_length(28) { value = new char[max_length+1]; value[0] = '\e"; // Default constructor size is 20 stringvar(int size); // Takes an int for size stringvar(const char cstr[]); // Takes a c-string and copies it stringvar(const stringvar& strobj); // Copy Constructor -stringvar(); // Destructor int size() const { return max_length; } // Access capacity const char* c_str() const { return value; } // Access value int length() const { return strlen(value); } // Access length stringvar& operator= (const stringvar& rightobj); stringvar& operator+= (const stringvar& rightobj); std::istream& operator>> (std::istream& in, stringvar& strvar); std::ostreame operator<« (std::ostream& out, const stringvar& strvar); private: int max_length; char value; };
RESPONSE AREA
Organize answer blocks in the proper order:
ANSWER BANK
Move the necessary blocks over into the response area:
delete [] temp;
char* temp = this->value;
strcat(this->value, rightobj.c_str());
return *this;
this->max_length = newlen;
# // Concatenation assignment operator= for StringVar class.
}
# if (this == &right0bj) return *this;
10
# #include <cstring>
11
strcpy (this->value, temp);
12
# StringVar& StringVar::operator += (const StringVar& rightObj) {
13
if (this->max_length < newlen) {
14
# this->value[0] = '\0';
# #include "StringVar.h"
this->value = new char[this->max_length+1];
int newlen = length()+rightObj.length();
this->value = nullptr;
Transcribed Image Text:RESPONSE AREA Organize answer blocks in the proper order: ANSWER BANK Move the necessary blocks over into the response area: delete [] temp; char* temp = this->value; strcat(this->value, rightobj.c_str()); return *this; this->max_length = newlen; # // Concatenation assignment operator= for StringVar class. } # if (this == &right0bj) return *this; 10 # #include <cstring> 11 strcpy (this->value, temp); 12 # StringVar& StringVar::operator += (const StringVar& rightObj) { 13 if (this->max_length < newlen) { 14 # this->value[0] = '\0'; # #include "StringVar.h" this->value = new char[this->max_length+1]; int newlen = length()+rightObj.length(); this->value = nullptr;
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,