I have overridden:
void* operator new(size_t count);
And when I construct an std::string it calls that function I'm assuming when it calls new. What I'm wondering is how does it know? The linker links with my function, not the standard C++ new. I understand the compiler can do this if it's linked statically with the runtime library (I'm guessing std::string) is defined(the code resides in) the runtime library. If it were linked statically with the runtime library then it would see the runtime library version, and my version, and since mine is "user-defined" it links with mine. However if the library is linked to a dll (runtime library), then a call to std::string's constructor resides in a .dll, which would call the standard operator new function. Is that what happens? Can a .dll call another library?
Anyway, I don't see how this is possible. My point being is that since the call to operator new isn't made in the header file of < string >, and since it's not linked statically, the compiler and linker doesn't even know that a call to operator new is made by the std::string constructor. On startup of the program the program looks for the String constructor and calls it in the .dll.