Solved

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

Posted on 1998-07-17
2
162 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

910 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

21 Experts available now in Live!

Get 1:1 Help Now