This is a first step for somebody that is a beginner. Same thing happened to me:
Look in the Solution Explorer box to the left. Make sure that there is actually a .cpp
file there. You can do the same by looking the .cpp
file where the .sln
file for the project is stored. If there is not one, then you will get that error.
When adding a cpp file you want to use the Add new item icon. (top left with a gold star on it, hover over it to see the name) For some reason Ctrl+N does not actually add a .cpp
file to the project.