Hey, I'm afraid this is probably a bit of a noob question but I'm having trouble finding a definitive answer.
If I create a c++ class via the editor, open it and then in the construtor in the cpp add something like:
When I start typing that first UStaticMeshComponent Visual Studio recognises it enough to be able to autocomplete and I can assign it assuming I don't need to cast. If I try and do anything with it though, I'm told it's an incomplete type and I have to
My understanding of the above is that UStaticMeshComponent is forward declared and so the compiler knows what it is, but can't do anything with it until it is defined (which happens when I include its .h file).
If I've understood the above correctly, then at what point is UStaticMeshComponent (and other components) forward declared? Is it when I use it as part of the line I pasted at the top of my post
Thanks for your help.
asked Sep 18 '17 at 11:22 AM in C++ Programming
Hi Magic Kiwi (good name) You are confusing terms, lest say you have a .h and cpp. and you want use that code inside another pair, and viceversa, this will create a circular dependency, and that means bad things for your compiler, in order to avoid this situation we use forward declaration. Here the example to illustrate this point:
As you can see you have been included the headers for each other, but this is wrong, the proper way is through forward declarartion:
also you can declare methods like this void SomthingElse(class ClassB* InClassB);
Now About your question, VS is very dump, the fact that is not capable to autocomplete stuff is a different history, whenever you added a module, class or something big to your project, try to regenerate your solution, this will fix the autocomplete feature 99% of cases
Follow this question
Once you sign in you will be able to subscribe for any updates here