I've had a bit of a google for overloading the assignment operator, and it seems pretty decent. I'm a bit confused about using constant references and all that but I'll learn. What I'd like to know is how to overload with a common data type. For example, I'd like to overload "char *" so that assigning a static string to a char pointer just copies the text. Ie:
I know I'll run into problems here, seeing as chTemp now points to a location within module memory (or whatever it's called), and I'm attempting to delete a block that is somewhere else.Code:char *chTemp=new char[256]; chTemp="Text"; delete [] chTemp;
I know I can just use strcpy(), but I seems such a waste of time. Could anyone show me how to overload "char *" for this purpose?