#include<iostream.h> #include<stdlib.h> #include<string.h> class String { private : char string [ 30 ] ; public : String ( ) { strcpy ( string , "" ) ; } void getString ( ) { cout << "Enter the String : " ; cin >> string ; } void display( ) { cout << "The String Is : " << string << endl ; } // Declaration (prototype) of overloaded sum operator String operator + ( String & s ) ; String operator += ( String & s ) ; void main() { String s1,s2,s3; s3=s1+s2; s3.display(); } }; String String :: operator + ( String &s ) { String temp; // Declared object temp of String type strcpy ( temp.string , "" ); // Initialized the temp with empty string strcat ( temp.string , string ); // Concatenated the driving object's string to //temp object strcat ( temp.string , s.string ); // Concatenated the argument's string to the // temp object return temp; // Returned the temp object } String String :: operator += ( String &s ) { String temp; // Declared object temp of String type strcpy ( temp.string , "" ); // Initialized the temp with empty string strcat ( temp.string , string ); // Concatenated the driving object's string to //temp object temp=temp+s; return temp; // Returned the temp object }