Microsoft Visual Studio 2022
I’m not sure whether this issue is about different settings between VS 2019 and 2022, or old project source folder structure ported to a new VS project,
But I encountered an annoying problem, of newly generated class files that can’t include or be included by other classes that already exist in the project.
Forgetting that the VS explorer window doesn’t display the actual folder structure, it took me some frustrating investigation to find out, that a new class was simply added to the root folder of the project, rather than the ‘Source’ folder within the project folder, where all the other classes are found.
Fix the problem for an existing class:
Move the new files manually to the correct location, and manually update the .vcxproj file with the new path:
The example in this image shows a new class named ‘baba’, that was moved from the root folder to the ‘Source’ folder, so the path was updated accordingly:
Creating a new class:
In the add new class dialog,
Press the file path button for the .h and .cpp files, and select the wanted folder.
This may be confusing, as after selecting the path, the dialog doesn’t reflect your selection, but it works.
I did some searching and..
It seems you can’t set the default location for new classes in a VS C++ project..
If you know otherwise, I would be very grateful if you’ll add a comment about this.