He, I need some help because of I can't figure out what it shows me strange numbers in the output
I mean. It works for instance name_1 + name_2
but I get extra some characters Anna+Mark&@#$@@ just for example.
class String
{
private:
char* str;
int len;
static int num_strings;
static const int CINLIM = 80;
};
String& operator+(String& st, String& st2)
{
char* napis = new char[st.len + st2.len];
int i;
for (i=0; st.str[i] != '\0'; i++)
{
napis[i] = st.str[i];
}
napis[i] = '+';
int static j = i+1;
for (int a = 0; st2.str[a] != '\0'; a++,j++)
{
napis[j] = st2.str[a];
}
st2.str[j] = '\0';
for (int i = 0; i < j; i++)
{
cout << napis[i] << std::endl;
}
delete st.str;
strcpy(st.str, napis);
return st;
}