I was reading the following text from Stanford’s Programming Paradigms class, and I noticed that when the author uses the string class, the constructor does a function call that looks like this:
string::string(const char* str) {
initializeFrom(str, str + strlen(str));
}
If the initializeFrom function takes two char* arguments, how come the second argument can pass a (char* + int) to a char* and have it work out properly? How does the type system interpret this statement?
Thanks in advance.
That is called pointer arithmetic. A char* + int results in a char* that is int characters higher in memory.