Is there an error here? And why would you have - * / operations? Also, you should make a copy of initialConstructorValue. Otherwise memory management will be a huge pain.
You shouldn't use = on char*'s. Use strcpy() instead (#include <cstring> ).
If you use =, it copies the pointer rather than the actual data. This means that when the actual data is changed or is deallocated, the string object is affected as well when it shouldn't be.
the - / are implemented in a way that ill explain later. the * is like ruby strings. what do you mean make a copy? and yes. i tried making an object and initializing it and then printing it but it gave me an error
Well that seems like a reasonable complaint. The strcat command accepts objects of type char-pointer, and you're trying to feed it objects of type DTSString. What did you think would happen?
well what am i supposed to do to add the strings together then?
You're supposed to pass strcat two char* objects. Is that not obvious from reading the strcat documentation?
1 2 3 4 5 6
friend DTSString operator+(DTSString stringOne, char charOne)
{
// Here ytou will need to do something to make sure stringOne.currentStringValue has enough space to add this one extra char you want to add
std::strcat(stringOne.currentStringValue, &charOne);
return srtingOne;
}
becuase DTSString is technically a char* with just more features
EVERY object is technically some basic objects with more features. It's up to you to tell the compiler what to do with them.
yeah i realized that i just need to pass the char *'s instead of the object. so now i have two questions. it lets me add two DTSStrings together but that was because i overloaded it, but why does it let me put the value in a third one with the = operator w/o overloading it? and my second is do i have to overload the << operator to cout it? and if so how?