Incomplete type is not allowed

Hello there, I am trying to learn unreal engine with C++ The book I am following has this example in somewhere in a cpp class.

  if (MeshAsset.Object != nullptr) {
    BoxOne->SetStaticMesh(MeshAsset.Object);
    BoxOne->SetCollisionProfileName 
    (UCollisionProfile::Pawn_ProfileName);
    BoxTwo->SetStaticMesh(MeshAsset.Object);
    BoxTwo->SetCollisionProfileName 
    (UCollisionProfile::Pawn_ProfileName); 
  }

So, when i paste this code in VS and try to compile I get “Pointer to incomplete type is not allowed” error and can not compile. But when i ctrl+clicked on the Pawn_ProfileName I saw it was just FName(TEXT("Pawn"))

So I replaced both of them with FName(TEXT(“Pawn”)) and it compiled. But I want to know why I can’t compile it the way it is in the book. Why the code block with UCollisionProfile::Pawn_ProfileName doesn’t work?

You probably forgot to include the collisionProfile header.

#include "Engine/CollisionProfile.h"

without that it has no idea what Pawn_ProfileName really is.

You were right, I’ve tried it with the include statement you shared and it just works fine. The book I’m using didn’t mention that.

But I have another question. While the include statement isn’t mentioned, how am I able to ctrl+click the class and find it. IDE knew it was a class and where it was located. I would expect it to say “hey I don’t know what it is and I don’t know what it means” Is this some kind of VS magic or something else related to C++ that I do not know?

I don’t have a clear answer to that but it should at least have some squiggly lines and telling you “incomplete type is not allowed” if you point at it. Visual Assist is a plugin that many use that will make it easy to include the necessary header.