plz chk my code i m having error at line 35 and 36
#include <iostream>
#include <cstring>
using namespace std;
class strng
{
char s[30];
public:
strng()
{
strcpy(s,"");
}
string getstring()
{
cout<<"enter the sting:";
cin>>s;
return s;
}
void displaystring()
{
cout <<"the string is:"<<s<<endl;
}
const strng &operator+= (const strng &t);
};
const strng &strng ::operator+=(const strng &t)
{
strng temp;
strcpy (temp.s,"");
strcat(temp.s,s);
strcat(temp.s,t.s);
s=temp;
return s;
}
main()
{
strng s1;
strng s2;
s1.getstring();
s2.getstring();
s1+=s2;
s1.displaystring();
}
errors are:
35 C:\Dev-Cpp\ddd.cpp incompatible types in assignment of `strng' to `char[30]'
36 C:\Dev-Cpp\ddd.cpp invalid initialization of reference of type 'const strng&' from expression of type 'char*'