Consider this situation: We write code that works well until we include a header file that happens to have an function overloading one of our original functions. In this case, there maybe some places where the calling of function goes to the overloaded version for better fitting of parameters, which is also logically unexpected. What's worse, compiler doesn't complain.
Here is a demo to clarify my question:
/*
For simlicity, I write the codes in different files in this way;
Whether include header.h behaves differently
*/
// main.cpp
#include "header.h" // If included, sb will be overloaded
#include<iostream>
void sb(int){std::cout << "int" << endl;}
int main(){
sb(3.5);
return 0;
}
// header.h
void sb(double);
// hehe.cpp
void sb(double){cout << "double" << endl;}
I have no idea whether this problem happens frequently or not, and wonder if there is any way to solve or prevent it.