I cannot add new C++ component to my actor door

after creating my new component of my actor door it showed this


and after compiling code its giving following error:

I’d suggest you compile with the editor closed. From within VS Code do the following.

Ctrl + Shift + B > ProjectNameEditor Platform Development Build.

Where ProjectName is the name of your project and Platform is the platform you’re targeting e.g. Win64

It’s showing the above error

Actually i have changed my project location from intial folder on C drive to
C: >programfiles>epicgames>Unrealengine> since I Thought both UE main file and projects must be under same folder. Is this cause of this error?

Yes. The generated VS Code files would be for UE4 instead of your project. You would need to move it out of there and then regenerate them from the Unreal Editor File menu