Tuesday 31 March 2015

Program to concatenate two object’s content (using string)

#include <iostream.h>
class concat
{
char *a;
public:
concat(char *b)
{
a = b;
}
concat operator+(concat c)
{
concat temp;
strcpy(temp.a, a);
strcat(temp.a,c.a);
return temp;
}
void show(void)
{
cout<<”The string is”<<a<<endl;
}
};
void main()
{
concat A(“Have a”);
concat B(“ Nice Day”);
concat D(“ “);
D = A + B;
D.show();
}

No comments:

Post a Comment