Because _tmain
is mangled in the binary with the class name MainClass
in it, so multiple classes could have a function _tmain
in them and not conflict. It's not got the same mangled name as ::_tmain
is going to have.
I remember that with an earlier version of MSVC, it accepted the following without a linker error which ended up accidentally as a result of macro expansion in my code base once
namespace bar {
int main() { }
}
It apparently treated the name main
specially and didn't mangle it or mangle it the same as ::main
. But such a thing is not Standard conformant. Like in the class case, such a function is completely unrelated to the main function.