Write a C++ program that overloads the + operator and relational operators (suitable) to perform the following operations:
- Concatenation of two strings.
2. Comparison of two strings.
#include<iostream>
#include<string.h>
using namespace std;
class con
{
char str1[50],str2[20];
public:
void getdata()
{
cout<<"Enter the two strings"<<endl;
cin>>str1;
cin>>str2;
}
con operator +(con b)
{
strcat(b.str1,b.str2);
return b;
}
void display()
{
cout<<str1<<endl;
}
con operator ==(con b)
{
if(strcmp(b.str1,b.str2)==0)
{
cout<<"Equal";
}
else
{
cout<<"Not Equal";
}
}
};
int main()
{
con a,b,c;
b.getdata();
b=a+(b);
b.display();
b=a==(b);
}