#include <iostream>
#include<string.h>
using namespace std;

class mystring
{
   char *str;
    int len;

   public:
   mystring() : str(nullptr) ,len(0){}

   mystring(const char *res)  // parameterized constructor
   {
       int l = strlen(res);
       str=new char[l];
       strcpy(str,res);
   }

   mystring(const mystring &ms)   //copy constructor
   {
      int l = ms.len;
      str = new char[l];
      strcpy(str,ms.str);
   }

   mystring(const mystring &&ms)  //move constructor
   {
       int l = ms.len ;
       str = ms.str;
       ms = nullptr;
       ms.len = 0;
   }

   mystring operator=(const mystring &ms)  //copy assignment operator
   {
         if(this != &ms)
         {
             delete[] res;
             int l = ms.len;
             str = new char[l];
             strcpy(str,ms.str);
         }
       return *str;
   }

  friend ostream& operator<<(ostream &out,const mystring &ms)  //operator overloading 
  {
    out<<ms.str;
    return out;
  }

  friend istream& operator>>(istream &in,const mystring &ms)  //operator overloading 
  {
    in>>ms.str;
    return in;
  }

};

int main() {

    string str1;
    string str2 = "Hello";
    string str3 = str2;
    string str4;
    str4=str3;

    int len = str.length();
    cout<<str4;
    cin>>str1;
    string str6 = std::move(str1);
    
    


    
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: