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

Write a driver program for the given class: ------------------------------------

ID: 3620307 • Letter: W

Question

Write a driver program for the given class:
-----------------------------------------------------------
class String1 {
private:
char str[80];
public:
// Constructors
String1();
String1(char *);

// Fill a character buffer argument
void GetString(char *);

// Concatenation Operators
String1 operator+(String1 &);
String1 operator+(char *);
friend String1 operator+(char *, String1 &);

// Assignment Operators

// would work without this cuz we do not have
// any pointer members but do anyway for practice
String1 operator=(String1 &);
String1 operator=(char *);

// Console Stream Output
friend ostream &operator<<(ostream &, const String1 &);
};
---------------------------------------------------------

The parts I have marked in red are the parts I'm having the trouble with... For the life of me, I just cannot seem to get char-anything working tonight.

The parts I have marked in red are the parts I'm having the trouble with... For the life of me, I just cannot seem to get char-anything working tonight.

Explanation / Answer

#include #include #include using namespace std; class String1 { private: char *str; public: // Constructors String1() { } String1(char *newstr){str= new char[strlen(newstr)]; strcpy(str,newstr);} // Fill a character buffer argument void SetString(char *); // Concatenation Operators String1 operator+(const String1 &)const; String1 operator+(const char *)const; friend String1 operator+(char *, String1 &); // Assignment Operators // would work without this cuz we do not have // any pointer members but do anyway for practice String1 operator=(const String1 &); String1 operator=(char *); // Console Stream Output friend ostream &operator
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