In Visual Studio 2010 I created a test C++ project, with precompiled headers. So, Test1.cpp got created. When ever I hit run the code present in this file gets executed by default.
Suppose I manually add test2.cpp in the existing project. Then where should I change the setting in such a manner that after clicking run it executes the code present in test2.cpp by default.
Any help is appreciable!!!
After it’s all compiled, the final binary doesn’t know which file the code came from. (It’s in the debug information, but that isn’t used to run the code.) Instead, it runs whichever block of code has the correctly named entry point, in this case
(or probably
_tmainfor Unicode / not).Do you have a main function in both files? That would cause linker errors. I suggest you just rename one out of the way, e.g. rename the one you don’t want to run to
main_test1and the one you do tomain.