Helllow
#include
#include
using namespace std;
/** AIM : Write a class for concatenation and printing strings
* variable to store string data
* create Print() to display stored String
* create OP + overloaded function to concatenation of 2 strings
*
*/
class String{
char str[30];
public:
// Default constructor
String(){
strcpy(str, "\0");
}
// Parameterized constructor for storing string / array of char
String(char data[30]){
strcpy(str, data);
}
// Destructor *optional
~String(){
cout<< "Obj is destroyed"< ";
myStr1.Print();
String myStr2("world");
cout << "myString2 obj ==> ";
myStr2.Print();
String result = myStr1+myStr2;
cout << "Concatenated String ==> ";
result.Print();
//------copy constructor is commented above class String-------
// String Copy(myStr1);
// Copy.Print();
}
// output:
// The string is :Hello
// The string is :world
// The string is :Hello world