Forward Struct Declaration impossible with C++?

I don’t understand why he says i can’t use that pointer there. :confused:
I just started on ue4 C++ this is my first code ever.

First off, why are you using a struct? Second, why would you need to forward declare the same class that is inside the .h file? Also, dont implement things in the .h file. Declare them in the .h file and define them in the .cpp file.

The problem is that you are implementing a struct. Structs are meant to be simple value types and are designed to be stored directly. You can use a reference or you can change it to a class. To expose anything it must be a subclass of UObject.

link text

HTH

I am trying to make a DCEL for a voronoi diagram algorithm, i already have used a lot C language and C# but never worked with C++, so basically just started learning it.
I do agree with the part when you say to implement in cpp file but what i don’t understand is why is this syntax not working it used to work in C and should normaly work on C++ as i saw in many websites. If you type linked list on C++ this is the normal syntaxe that is used.
So i don’t get why he don’t accept a pointer of the same struct knowing that i already forward declared it.
It’s just a pointer to the same struct it’s not a struct in it’s own.

Please change this comment to a comment and not an answer.
The reason it is not working is that you want to expose a struct using the UPROPERTY and to expose a complex type it must be a subclass of UObject. Also, dont use structs with functions. Just use a class.

Forward declaration at line 9 should looks like “struct FVertex;”, but not as “typedef struct FVertex FVertex;”. This is a C++ structure, but forward declaration refers to “C” syntax. Regarding “why structure but not class”, struct type is ok here. There’s no difference between struct and class declarations in C++, except struct will have all fields “public” by default. Unreal Header Tool works well with either declaration type, so there should be no errors with it.

I’m having issues trying to find a way to get a UStruct to work effectively in multiple files as well.

The reason this isn’t working, AFAIK, is that though you are forward-declaring the struct, you’re forward declaring just that, a struct, not a UStruct. Since UProperties can only hold certain types, (something along the lines of C++ types, UStructs, and UObjects,) and you can’t properly forward-declare something as a UStruct (AFAIK), it’s creating an error.

However, you can’t necessarily easily solve this problem using includes, as you quickly get a horrible tangle of includes that want to violently murder eachother, and thus create lots of errors.

It’s not a clean solution, but what I’ve just done as kinda’ a kludge is make an new actor C++ class, remove all of the actor code (leaving just the includes) and put my struct in there, which makes it a lot easier to include other places appropriately.