Darkloud1989, I’m sorry that I missed your follow-up question back in March. I didn’t read any bluntness in your question at all, I just was absent from the forum.
As for why this happened, I’m not an expert, but here’s my very un-expert understanding:
Because of UE4’s “include what you use” approach, the compiler that is compiling a header file is completely unaware of any other classes you have created, so it does not know what they are and won’t recognize them when you try to declare an instance of some other custom class. The only way the compiler will know anything about other classes is for you to forward-declare the class or have a “#include” at the beginning of the file.
In your code, when the compiler reached line 59, the first thing it saw was the word “AZephyrCharacter”. You and I know that you were declaring an instance of the class AZephyrCharacter. However, the compiler did not know of such a class. My non-expert understanding is that, in such a situation, the compiler takes a guess about what you are trying to do, and it generally guesses wrong. Specifically, when the compiler sees a name it does not recognize, it assumes you are declaring an integer with that name. So, it assumed “AZephyrCharacter” was an integer with the name “AZephyrCharacter.” Having made that assumption, it expected to see one of two things that follow the name when you declare an int – either (a) an initialization (i.e., an equals sign followed by a number), or (b) a semi-colon. In your line 59, it didn’t see either of those things. Instead, it saw an asterisk followed by the word “ACharacter,” which is not something the compiler understands immediately after an integer name. Again, I’m no expert, but think that in the absence of a forward declaration of a #include, the compiler read your original line 59 the same way it would read the following:
int32 MyInteger* SomeRandomWord;
In your line 59, you used the word “AZephyrCharacter” instead of the name “MyInteger,” but the compiler reads it the same way. You also used an asterisk and the word “ACharacter” instead of “*SomeRandomWord,” but the compiler doesn’t understand that syntax either way, and should always give you this error.
By forward declaring the class (or putting an #include of the class at the beginning of your header), you are now alerting the compiler to the fact that AZephyerCharacter is not the name of an integer you are declaring, but is instead the class of a variable you are declaring, and specifically a pointer variable with the name “ACharacter.”
Your follow-up post suggests that maybe you didn’t have this problem before? That sounds strange to me. If you didn’t forward-declare the class or #include it, then the compiler should have given you this error; the compiler should not be recognizing classes that you haven’t forward declared or included.
I hope this answers your question and is helpful. If I misunderstood your question, please let me know and I’ll take another stab at it.
Good luck with your game!