First of all this has nothing to do with UE4, it’s C++ thing. “Incomplete pointer or type” means that object or structure does not have content (variables) declared (in compiler terms, it’s incompletely declared), there for size of type in memory can not be determent and compiler can’t generate machine code for this type. Look here
class USoundCue* VoiceLine;
By placing “class” you actually declared class, so it actually equivalent of doing this:
class USoundCue;
It a declared class without content declered. In C and C++ each cpp file are compiled individually from 0 to object file that is later linked toghther with other object file to create wither exe or dll, so each cpp is compiled from absolute 0 state. #include
command pasted content of file to the specific point so when you include header file you put declarations of classes to file you use include in (and yes that means you can also include cpp files in cpp files, but it’s very rare cases), this way compiler knows about classes, what functions it has and how they are strctured regardless of starting from 0, saves that information in to object file and then linker at the end links those declerations and usage of fucntions with other object files where code of actual class is, resolving all gaps in information (thats why if you delcere function and don’t define code for it you get linker error, as linker can’t find code for it in any other object file to resolve all missing information about your class). But what is importent here for topic we talking here is to understand that each cpp file is compiled from 0 state and all classes need to redeclered for each file.
So C++ let you incompletely declare the class, if incomplete declared class is used (like you try make call to pointer of it) it will throw error as compiler lacks information about the class, but you can declare then class later on… and this can be preformed by including in cpp file a header file to actual class deceleration, so you missing:
#include "Sound/SoundCue.h"
Now you may ask, why you need to declere class like that in your header file? It’s called forward referencing and it’s a convention technique that is used in UE4, it uses the fact that compiler let you use incomplete class declarations where if unused is resolved during linking later on, to avoid making circular dependency in header files (ClassA ehader file having include to ClassB.h and ClassB have a include to class ClassA.h) which causes issues during compilation. This allows header files to have minimal includes as possible as incomplete declarations passes if unused, avoiding any circular dependency. It moves need to include header files to complete incomplete class declerations in to cpp file, so dependency is moved from header file to cpp file breaking any circular dependency in header file. Thats why in UE4 you only include base class in header file, as compiler needs complete class deceleration for base and nothing else and if specific type is used oyu add include in cpp, thats why you need to include “Sound/SoundCue.h” in your class. This technique does not work with all types, like enums or delegate (the way UE4 make them) types, so sometimes you are forced to include in header file, but thats rare cases
In short you if you get that error you need to include header file for incomplete type you using.