Solved

Debugging problem. operator+=(const char rhs) crashes.

Posted on 1998-07-17
2
161 Views
Last Modified: 2010-04-01
Thank you trestan.
0
Comment
Question by:TylerRick
2 Comments
 
LVL 11

Expert Comment

by:alexo
ID: 1168088
If you wish to award points to a specific expert, please say so in the title!
0
 
LVL 8

Accepted Solution

by:
trestan earned 100 total points
ID: 1168089
Thanks. Do not forget reject the original one. Otherwise you will not get your points back. The follows listed here for memo.
It is depends on how you define the length of the CString, especially in your constructor:
CString::CString(unsigned short len)
{
   itsLen = len+1; //You have declare itsLen.
   itsString = new char[itsLen ];
   for (unsigned short i = 0; i<itsLen; i++)
      itsString[i] = '\0';
}
Then the itsLen will be the actual length of the CString. Later, just itsLen+1 is enough. I think you should also define CString1 += CString2. However, you have known what is a complete set of operators. Good luck.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now