Assume I want to write my own string class. The string has a property char * s
which is a pointer that points to a character.
Now in the constructor, String::String()
, what would you pass in to assume another char *
to that? You can't really do something like the code below since both pointers will point to the same thing (and we don't want that):
String::String(const char *str) {
s = str;
}
Any help is appreciated!