Basic VS question: adding new class files

This refers to Visual Studio 2017 running on a Windows 10 machine.
Using an example project (say pointCloudExample) I wish to experiment with adding a class to the ‘src’ collection. Right click on “src” and the popup menu offers “Add” whose options include “Class”. That looks like what I want to do!
Selecting the Class option, I am able to enter a class name (say “Bogus”) which, after clicking on OK, creates Bogus.cpp and Bogus.h files. A new build on the project yields successful compilation.
But, wait, there’s more!
When I add #include “Bogus.h” inside ofApp.h, the compiler complains:
fatal error C1083: Cannot open include file: ‘Bogus.h’: No such file or directory (compiling source file src\ofApp.cpp)
This looks to me like the magic makefile is not getting the news about me adding a new class to the project. Clearly, I’m missing out on some very basic VS usage. Help…

I’ve never figured out how to manage this. When you create your class using wizzard, the files are created outside the src folder.
I always put my files (like Bogus.cpp and Bogus.h) to src folder outside the VS and then right click on the src folder in VS , Add Existing Item… and select my files. Now you can include a header file to ofApp.h and it works.

Thanks for the reply.

Your solution sounds like you use an external editor (my favorite, Sublime) or a second instance of Visual Studio to create the new class files and store them in …/src. Kind of clumsy but I’ll give it a try. I wonder how hard-core Microsoft developers handle a multi-class file program?

Same for me, kind of…
I have been always annoyed by the lack of automation in this process. One has to do EVERYTHING by hand, VS does absolutely nothing for you… but afterwards i realized that maybe that was not that bad at the end.

If you right click on a filter (a solution folder) in your project and go “add new item”, after setting the name you can give the path where the file will be created. this path will be remembered, so new files will show the last used path. I agree that it would be cool to have an option to always place files and filters as they are in the physical location. I still don’t understand why an option like that is not used. But didn’t research about it.
EDIT: there is an option for it:

Another issue, completely different thing, is that the files you add to your project won’t be found by the compiler if you don’t add the containing folder to the famous “Additional Include Directories” and i think it is a good thing that VS does not mess up with that at all. That must be done manually. I have used Xcode before and i think the process was kind of similar.

BTW i usually create the files out of VS (you don’t need any other external editor for that) and add them as @SebastianSobotka explained. Mostly because I usually create the new file duplicating an old one, to me its faster to delete code than to write it. But i guess that all depends on your laziness levels :grin:

good luck!

I do this the same way :slight_smile:

I appreciate all the comments and replies. But I don’t quite get this:

BTW i usually create the files out of VS (you don’t need any other external editor for that) and add them as @SebastianSobotka explained

One “creates” the files while not needing an external editor. Er, using what? Notepad?

Sorry for being dense.:grin:

I copy old files i.e SomeClass.cpp / SomeClass.h and rename to i.e. Bogus.cpp / Bogus.h. Next, I add as described above and then I edit them in VS.

OK, I get it. Kind of “bootstrapping” your way into Visual Studio.

As always, thanks for the input.