#include<iostream.h>
#include<conio.h>
#include<string.h>
class string
{
private:
char str[80];
public:
void showdata()
{
cout<<str;
}
void getdata()
{
cin>>str;
}
friend string operator +(string ,string);
};
string operator +(string s1,string s2)
{
string temp;
strcpy(temp.str,s1.str);
strcat(temp.str,s2.str);
return temp;
}
void main()
{
clrscr();
string s1,s2,s3;
cout<<endl<<"\nEnter first string:";
s1.getdata();
cout<<endl<<"\nEnter second string:";
s2.getdata();
cout<<endl<<"String 1:";
s1.showdata();
cout<<endl<<"String 2:";
s2.showdata();
s3=s1+s2;
cout<<endl<<"\nConcatenated String:";
s3.showdata();
getch();
}
#include<conio.h>
#include<string.h>
class string
{
private:
char str[80];
public:
void showdata()
{
cout<<str;
}
void getdata()
{
cin>>str;
}
friend string operator +(string ,string);
};
string operator +(string s1,string s2)
{
string temp;
strcpy(temp.str,s1.str);
strcat(temp.str,s2.str);
return temp;
}
void main()
{
clrscr();
string s1,s2,s3;
cout<<endl<<"\nEnter first string:";
s1.getdata();
cout<<endl<<"\nEnter second string:";
s2.getdata();
cout<<endl<<"String 1:";
s1.showdata();
cout<<endl<<"String 2:";
s2.showdata();
s3=s1+s2;
cout<<endl<<"\nConcatenated String:";
s3.showdata();
getch();
}
No comments:
Post a Comment