Once you have selected either Public or Private class when creating a new C++ class, then you do not appear to be able to NOT have a class be either Public or Private again for that project in the future (i.e., there’s no way to un-select ). This leads to issues with someone new to the system as header files are then no longer found for any newly created classes. There’s probably a way around that, but it sure would be nice to be able to go back to not having the value selected and having working headers for a simple project.
I’m not sure exactly what you’re referring to. I was able to create 2 classes based on Actor (both marked as private when creating them in the editor) and successfully compile after adding
#include "MyOtherActor.h" inside of the first class’s header file. Could you provide an example of what you’re reporting or give steps for me to reproduce the issue on my end?
At it’s simplest it comes down to once you select public or private for a class in the creation there does not appear to be a way to NOT select it in the future. When I create a new project neither is selected when I go to create a class, but after having selected one there is no way to un-select either of them.
The more complicated bit, which I suspect there may be a way around, is that VS then does not find my class.h inside the Public folder, and I then get every little thing in the class.cpp listed as an error, and no intellisense. This does not occur if I do not select Public or Private for the class on creation, as both files end up in the same directory.
I was able to reproduce the issue of the Public/Private being auto-selected when creating new classes and submitted a bug report for it (UE-28648). I have created both public and private classes but have not had any issues with Visual Studio not being able to associate the .cpp with the .h. Are you specifically using Public or Private (or do you have this issue with both)? Do you have the same association issue in a new project if you create a class without selecting either public or private?
I’m honestly not familiar with VC++ and header files, but the gist of the problem is that it’s not scanning the Public folder that it puts the header in in VS. Simplest re-creation for me is to create a new project, create a class that is Public, open the cpp and find that everything is marked as an error because it cannot locate the header in the Public folder. Header is in Public, and cpp is in Private.
I can solve the issue by manually adding that folder to the project include folder, but with a more complicated folder structure that’s not really a viable solution.
Otherwise, here’s what I get:
And if I right click on the MyActor.h and select the ‘Open Document’ function here:
So, VS obviously doesn’t know where that file is located by default.
Based on the third screenshot it appears to be looking for the the header file in the same Private folder that the source file is in. If you edit the include statement to show the full path to the header file ([ProjectName]/Source/[ProjectName]/Public/[HeaderName]) are you then able to compile the class?
Hey Doug, I can certainly use the following path for the include:
and that does work. I was expecting that when the UE editor creates a class for me it’s not broken by default though. Shouldn’t it create the “Public\…” if I have selected a Public class?
That is a part of the report I submitted previously. Until we have a chance to address this bug, adding the “Public” portion of the include manually will be the easiest workaround.
I’m facing the same issue since this bug is still there in version 4.18. I selected public ones and now I have no way to deselect it when creating new classes. It puts the header in public folder and cpp file in private. I can’t even open the public folder inside the editor and private folder isn’t even visible when both are there in the explorer.
I ended up deleting a whole bunch of files from the project and now it’s back to normal.
This is an old thread, but wanted to put my name down for having it fixed as I’ve run into this issue. It’s basically a trap for new users.
Unfortunately, the bug report for this issue (UE-28648) was marked as “won’t fix” over a year ago. However, I have been able to work around this issue. I’m using git source control with a standard gitignore like the one found at gitignore/UnrealEngine.gitignore at main · github/gitignore · GitHub . After cloning the project to a new directory, the problem disappeared. This means that the problem is in one of the local disposable files. I don’t know exactly which file that would be, but you could try deleting Binaries, Intermediate/Build, etc. Basically any of the files/directories found in the list at gitignore/UnrealEngine.gitignore at main · github/gitignore · GitHub .