I have been racking my brain for a couple days now on this homework assignment and I am still lost. This chapter is about memory management.
Here is the question
Continue implementation of the String class. Add each of the following
1. A constructor String(int n, char c) that initializes the string with n copies of the character c
2. The + operator to perform concatenation of two String objects.
3. the function call operator so that s(int start, int length) returns a substring starting at the given position of the given size.
those are the 3 problems I am having with this assignment, I can figure out the rest on my own
this is what my code looks like
String(const char p);//simple constructor
String(const String& right);//copy constructor
String& operator=(const String& right); //assignment operator
String& operator+=(const String& right);
int length() const;
char& operator(int index);
char operator(int index) const;
//exersise 15.3 begins here
String(int n, char c);//constructor initializes the string with n copies of c
string operator+(const String& right);//concatenate two strings
int compare(String);//compares if string is lexicographically less than, equal to, or greater than argument.
void resize(int n, char c);//changes the size of the string to n, either truncating characters from the end, or inserting new copies of character c
string operator()(const String& right);//returns a substring starting at the given position of the given size
Since I have to overload the + and the () operators how can I use another class object if member functions of a class only accept one parameter?