There is one annoyance in Visual C++ (2010/2012) for people used to C#’s solution/project folder behavior where a folder in the project maps to a namespace, and any files/classes you add to that folder are physically added to an equivalent subfolder in the file system. Unfortunately, with VC++, the closest equivalent is a project filter which is not a physical folder. There are some very obvious disadvantages to this approach.
- You cannot have the same filename under multiple filters. Example, if you have base.h under the data filter and you want to add base.h to the view filter, you cannot, since they are both in the root folder.
- A second issue is that when you #include files, you cannot use the filter name in the path, and have to use the physical path which may often be confusing.
- File organization also gets messy because all the files get created in one single folder.
A workaround that I use is to do this.
- I create a physical sub-folder inside the project folder.
- I then select “show all files” in the solution explorer and manually include this folder
- Then, I create a filter of the same name (as the subfolder)
- I then add new files/classes to this folder, and also drag/drop the file into the filter in solution explorer
Obviously, this is a bit of a hassle, but it’s still the simplest approach given the way they chose to make filters work. You can save one step by selecting the right folder when adding a file/class to a filter.
I hope the next version of VC++ will emulate the more intuitive and convenient behavior available for C# projects.