Although it's too late to add this answer, but it might be useful to the future-viewers. This is what I did -
While trying to figure out how to use Visual Studio for the very same purpose you asked, I observed and found that for a C++ project, there should be only one starting point, that is, only one main()
function.
So, instead of creating a new project every time, just change the name of (main()
) functions in the unused C++ files to something else, like the filename or anything.
For example, I first created my very first program hello_world.cpp
with a main()
function, and then compiled it, ran it & learned everything I could using it.
But now I want to create a new file for trying some other new thing (a new file learn_operators.cpp
with a main()
function of its own).
So, before trying to compile & run learn_operators.cpp
, I'll change the name of main()
in hello_world.cpp
to, say, hello_world()
, and then build & run the project in the same manner as before, but this time only this new file will run as this is the (new) starting point for the project (that is, it includes main()
function).
Hope this helps & correct me if I'm wrong anywhere.
Update: One other way is to keep one file with main()
, create classes for the other project code, including any new file/code added to the project, and then call those classes from main()
. This way, any piece of code other than main()
stays wrapped in classes, and only the code in main()
gets changed a bit every time new code has to be called, instead of renaming the functions to main()
.