Location of the error is indicated in a comment below. Please help fix this.
#include<iostream.h>
#include<string.h>
#include<stdlib.h>
class String
{
private:
enum{sz=80};
char str[sz];
public:
String()
{
strcpy(str,"");
}
String (char s[])
{
strcpy(str,s);
}
void display() const
{
cout<<str;
}
String operator +(String ss) const
{
String temp;
if(strlen(str) + (strlen(ss.str) < sz)
{
strcpy(temp.str,str);
strcat(temp.str , ss.str);
} // Error is reported here!
else
{
cout<<"\nstring overflow";
exit(1);
}
return temp;
}
};
int main()
{
String s1="\nMerry christmas";
String s2="happy new year";
String s3;
s1.display();
s2.display();
s3.display();
s3=s1+s2;
s3.display();
cout<<endl;
return 0;
}