I want to overload operator + in array that consider char .I want to print Hello Jack But it has eror in my program . How can I fix it?
class Test
{
private:
char s1, s2;
public:
Test() {}
Test(char a, char b) { s1 = a; s2 = b; }
void Print() { cout << "String1 :" << s1 << "\tString2 :" << s2 << endl; }
Test operator+(const Test& r)
{
Test temp;
temp.s1 = s1 + r.s1;
temp.s2 = s2 + r.s2;
return temp;
}
};
//////////////////////////////////////////////////////////////////////////
int main()
{
char str1[] = "Hello";
char str2[] = " Jack ";
Test t1(str1[]);
Test t2(str2[]);
Test temp;
temp = t1 + t2;
temp.Print();
}