#include<iostream.h>
#include<conio.h>
#include<string.h>
const int buff_size=50;
class string
{
private:
                char str[buff_size];
public:
                string()
                {
                                strcpy(str," ");
                }
                string(char *mystr)
                {
                                strcpy(str,mystr);
                }
                void echo()
                {
                                cout<<str;
                }
                string operator +(string s)
                {
                                string temp=str;
                                strcat(temp.str,s.str);
                                return temp;
                }
};
void main()
{
                clrscr();
                string str1="Welcome To ";
                string str2="Operator Overloading ";
                string str3;
                cout<<"\nBefore str3 = Str1 + Str2; . . ";
                cout<<"\nStr1 = ";
                str1.echo();
                cout<<"\nStr2 = ";
                str2.echo();
                cout<<"\nStr3 = ";
                str3.echo();
                str3=str1+str2;
                cout<<"\nAfter Str3 = Str1 + Str2; . . ";
                cout<<"\nStr1 = ";
                str1.echo();
                cout<<"\nStr2 = ";
                str2.echo();
                cout<<"\nStr3 = ";
                str3.echo();
                getch();
}
Advertisements