i'm getting frustrated with this lines of code, it's something about operator= , everything compiles fine, but program crashes during that crap,i'm still a noob so don't burn me for something obvious,here's the code:
If you are a noob you shouldn't even be attempting this at all. You should be using std::string. It always astounds me when I see a noob trying to implement a custom string or dynamic array class. This is a task that even the most experienced programmers would need to put a great deal of effort into.
You don't have an assignment operator at all. The correct declaration is String& operator=(const String& rhs);
If character arrays could be copied as easily as how you attempted to do it we wouldn't need a std::string class in the first place. All that you are doing is copying 1 character from the rhs char array to the lhs char array. If you want to copy a c-array you have to use strcpy or strncpy. You also have to ensure that enough memory is allocated on the lhs.
You need to read up on the assignment operator. There are many, many threads available on the subject. That is if you really insist on finishing this. I recommend that you use std::string until you are more experienced.
@ Kempofighter: hey I aswell am a newbe at advanced coding but im working on it my question is what is the difference between using namespace std; and std::string; personally i like the u.n.s; then the s::s; only because 99% of all my books use the u.n.s; method im not being mean but im just wanting some extra info on the pros and cons between the to thanks