#include<iostream>
#include<string>
using namespace std;
class string
{ char *a;
int b;
public:
string() {a=0; b=0;}
string(char *c)
{
b= strlen(c);
a= new char[b+1]; //b+1 because one char extra for space
strcpy(a,c);
}
friend void show(string s);
friend string operator+(string &s1, string &s2);
};
string operator+( string &s1, string &s2)
{
string s3;
s3.b= s1.b+s2.b;
s3.a= new char[s3.b +1];
strcpy(s3.a, s1.a);
strcat(s3.a, s2.a);
return(s3);
}
void show(string s)
{
cout<<s.b;
}
int main()
{
string s1("New");
string s2("Delhi");
string s3;
s3= s1+s2;
system("pause");
}
this is the code of my hw problem.....it does not work in my compiler.....i cant find the error in it...