Create a C++ class MyString with data member character pointer. Write a C++ program to accept and display a string. Overload '+ ' operator to concatenate two strings.
#include<iostream.h>
#include<conio.h>
#include<string.h>
class
string
{
char
*cp;
int
len;
public:
void
input()
{
cout<<"Enter
your string: ";
cin.getline(cp,20);
}
void
display()
{
cout<<"String:
"<<cp;
}
void
get(char *s)
{
len=strlen(s);
cp=new
char[len+1];
}
{
string
obj;
strcat(cp,s.cp);
strcpy(obj.cp,cp);
return
obj;
}
};
void
main()
{
string
s1,s2,s3;
s1.input();
s2.input();
s3=s1+s2;
s3.display();
getch();
}