すいません教えてください以下のようにソース書いてたのですが
class StrType{
char *p;
public:
StrType(){p = NULL;}
StrType(char *Array);
~StrType(){ delete p;}
StrType(const StrType &STobj);
StrType &operator=(StrType &STobj);
StrType &operator+=(StrType &STobj);
char *Get();
friend StrType operator+(StrType &STobj);
};
StrType::StrType(char *Array){・・・}
StrType::StrType(const StrType &STobj){・・・}
StrType &StrType::operator =(StrType &STobj){・・・}
StrType &StrType::operator +=(StrType &STobj){・・・}
char *StrType::Get()
{return this->p;}
StrType operator+(StrType &STobj1, StrType &STobj2)
{
StrType Temp;
Temp.Get() = new char [strlen(STobj1.Get()) + strlen(STobj2.Get()) +1];
strcpy(Temp.Get(), strcat(STobj1.Get(), STobj2.Get()));
return Temp;
}
最後のoperator+の構文がうまくいかないです。
以前ここで、四則演算の演算子のオーバーロードはフレンドが好ましいと聞いたので
フレンドでなんとかやろうとしてるんですが、上手くいかないです。
Temp.Get() = new char [s・・・の式の左のオペラントが正しくないとエラーがでます。
メンバにしてしまえばいけるんですが。
こういう場合はメンバにするしかないんでしょうか。教えてください。