Quote Originally Posted by Daved View Post
>> String::String(char letter, int repeat) : name(0), stringlength(repeat)
That constructor isn't quite right, but from the looks of it you added it recently and with a different style than your other ones.

The other constructors have solved the initialization problem I mentioned before, except now one of your operator= does the same bad thing of not setting all values to valid states.

Look at how your operator+= sets stringlength at the end of the function. It's not quite right.

Your operator=(char) has a memory leak. Remember that you need to clean up existing memory inside operator=. Also check your setName function for the same problem.

I assume you haven't used your operator[] functions yet. You'll see the problem when you do.


Do you have test code? You should write a small test app that tests one function at a time. Start with a string, run one of the functions, and check the values inside the string to make sure they are accurate. do this for every function separately, and then they should work better when you combine them.
You are right. I made the String(char letter, int repeat) constructor but I changed some of it according to the suggestions of another user and it works better now.