更新时间:2023-01-25 23:30:52
这是初学者的第一步.我也发生了同样的事情:
This is a first step for somebody that is a beginner. Same thing happened to me:
在左侧的解决方案资源管理器框中查看.确保那里确实有一个.cpp
文件.您可以通过查看存储项目的.sln
文件的.cpp
文件来执行相同的操作.如果没有,那么您将得到该错误.
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.
添加cpp文件时,您要使用添加新项图标. (上面有金星的左上方,将鼠标悬停在上面可以看到名称).出于某种原因, Ctrl + N 并没有将.cpp
文件实际添加到项目中.
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.