Even though functions are implemented in two separate source files, if they belong to same namespace, the linker would be confused which one to use for linking and ends up in throwing error.Originally Posted by sprit
Yes both the functions have different scope (as not declared in include files), but scopes are different for compiler & linker. For compiler, scope is single translated unit (including any extern symbols). Linker's job is to connect all the translation units, to so form the final executable, so for linker the scope includes all translations units, and hence the error.Originally Posted by sprit
C++ provides various ways to deal with situation, like namespace separation, object encapsulation using classes / structs, function overloading etc, you can use one of these methods.
Bookmarks