#include #include "silly.h" using namespace std; using namespace shomper_silly_class; void printPrompt(string s) { cout << "global: " << s; } int atoi(char *num) { cout << "My atoi " << num << " "; return 0; } int main () { silly s; char num[] = "16"; // The call to printPrompt calls the global version, since silly.h does not // export the identifier "printPrompt" there is no name conflict printPrompt("Is this going to cause trouble? "); // The first call to atoi() calls the version from the std namespace, since // the character literal matches the "const char *" type for this function. // The second call to atoi() calls the version defined in this file. Why // is there not a name conflict when the main is linked to the standard // libraries (or for that matter with the archive in this directory)? This // is because in linking, we pull in only those references which are still // unresolved. However, if we try to link main.o with atoi.o, then we have // a multiple defintion, because the code for these functions is already // present in the object files. cout << atoi("16") << endl; cout << atoi(num) << endl; s.getInfo(); s.printInfo(); return 0; }