CS1500 Algorithms and Data Structures for Engineering, FALL 2012

HW6 String class

Implement your own string class. You cannot use any  C++ built-in string functionality (like the function strcmp).

class mstring{
private:
    char* data;
    int size_allocated;
    int current_size;
  
public:
  mstring();                 //constructor, default
    mstring(char*);         //constructor from a c-string
    mstring(const mstring&)         //copy constructor
    ~mstring();
  resize(int); 
  length();
  append(mstring string2);
  compare(mstring string2);
  erase();
    find(mstring string2);  //find the first starting position of substring  string2 in the current string (if string2 is a substring of the current string)
    copy(char* source, int position, int size);
    substr(int position, int size);
  operator [](int pos);     //to get a character from string by position
    operator <<;        //to be able to display the string by calling cout<<...
}  

The pseudocode is required only for the functions compare() and find().