Advertisement
rex9840

concatination

Mar 5th, 2021
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3. using namespace std;
  4.  
  5. class String_{
  6. private:
  7.   string str1;
  8. public:
  9.     String_(){this ->str1="";}
  10.     String_(string str):str1(str){}
  11.  
  12.     String_ operator +(const String_ str2){
  13.         String_ mediator;
  14.         this->str1=this->str1+str2.str1;
  15.         mediator.str1=this->str1;
  16.         return mediator;
  17.  
  18.  
  19.     }
  20.    
  21.     void display(){
  22.         cout<<"the cncatinated string is  ---->>> \t "<<str1<<endl;
  23.     }
  24.  
  25.  
  26.  
  27. };
  28.  
  29.  
  30. void concatinate(string,string);
  31. int main(){
  32.     string source,destination;
  33.     cout<<"enter the string which you want to concatinate::"<<endl;
  34.     cin>>source;
  35.     cout<<"enter the destination string::"<<endl;
  36.     cin>>destination;
  37.     concatinate(destination,source);  
  38. }
  39.  
  40.  
  41.  
  42. void concatinate(string des,string sour){
  43.     String_ destination(des);
  44.     String_ source(sour);
  45.     String_ concat=destination+source;
  46.     concat.display();
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement