Put those main
functions in separate namespaces and then define, which one do you want to run, eg.
File1.cpp
namespace F1
{
int main(int argc, char * argv[])
{
// ...
}
}
The-real-main.cpp
int main(int argc, char * argv[])
{
if (whatever)
return F1::main(argc, argv);
}
Edit: In response to additional information.
C++ is not Java and VS is not Eclipse :) The natural way to maintain multiple programs at once in VS is to put multiple projects (one for each executable or library) in a single solution. If you want to run a project, simply right-click it in Solution Explorer
, select Set as Startup Project
, and then click the Start
button to run it.
To add a project to solution, right-click the solution and choose Add
| New project...
or Add
| Existing project
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…