There is nothing wrong with the lack of warnings in this instance. The compiler does its job with the information it's given... in this case, it compiles (separately) the two source files into two object files. These files are fine individually. The problem comes when the linker tries to combine the two object files into a single executable that the duplicate code problem comes into play. You may have avoided problems here also by removing class.cpp from the project (but I wouldn't recommend this in this case), then the compiler would not touch it all and you'd essentially have a single source project to compiler/link and the #include directive would have worked (although not as intended for a source file).