programming quick start - and compiler doesnt like it

Hi everyone !

I recently started to learn programming with unreal engine 4 and I encountered a problem :

I was reading this quick guide :

and followed step by step. but i get errors in visual studio. i uploaded a screenshot.
And here are the error messages i get, and under these the code which is red underlined.

the classtype pointer-to-incomplete is not permissible

a name followed by :: has to be a class or namespace

the identifier “CubeVisualAsset” is not defined

Can someone please help me out here?

The Intellisense has given up tracking down the missing include for UStaticMeshComponent, **UStaticMesh **and ConstructorHelpers. This code should still compile though since the Actor class that the class inherits from includes those.

However it is a good practice to explicitly include what you need, and you don’t have to worry about including the same thing twice since the

#pragma once

directive in the header file will ensure that everything is only included once.


#include RotatingCube.h

you should add

#include "Components/StaticMeshComponent.h"

UStaticMesh is within **UStaticMeshComponent **so you don’t have to include that.

Also add

#include "ConstructorHelpers.h"

Why is it a good practice to explicitly include things you might ask?

When you don’t explicitly include things you need but expect it to magically be included somewhere else you can end up with having to sort out missing includes in a lot of places if the “magic” include suddenly doesn’t exist anymore.

The order of includes also matters so if something isn’t included until after you need it then the build will fail.

The intellisense has an easier time tracking things and you get rid of the intellisense errors.

By including it where you need it you avoid these problems.

Go even further than that, there’s a really good practice I follow when coding UE C++, and it goes like this:

  1. Use component, say for example UStaticMeshComponent.
  2. Right-click UStaticMeshComponent type and go Quick Actions -> Add Include
  3. Google “unreal engine C++ api UStaticMeshComponent”
  4. Grab the module name from the resulting API page and add it to your build.cs file if it isn’t already there.

If you start getting poorly formatted errors about __cdecl then you did one or more of the following:

  1. Didn’t declare the type you’re using
  2. Didn’t include its header
  3. Didn’t add its module.

I used to forget the module all the time and spend hours ramming my face into the desk trying to work out what was going wrong. It’s always one of the above.

thank you 4 your answers.

I will try to find a solution to my problems, and if i do, i will post it here. If I dont, I will post again and edit this post here.

edit: I tried but failed again. This time though there are “only” 3 errors I need your help with.

In my cpp File :

// Called when the game starts or when spawned
void ARotatingCube::BeginPlay()


The Word BeginPlay is marked red and it says : “Class UObject” doesnt have a member “BeginPlay”.
As far as I know, if a class inherits members from another one, then we should be able to use its functions. I took a look at the documentation and it said that the class AActor contains the function BeginPlay. But why does the error message mention UObject? didnt our class inherit everything from AActor and with it the things of UObject? The same error message was shown at the following:

// Called every frame
void ARotatingCube::Tick(float DeltaTime)
FVector NewLocation = GetActorLocation();
FRotator NewRotation = GetActorRotation();
float RunningTime = GetGameTimeSinceCreation();
float DeltaHeight = (FMath::Sin(RunningTime + DeltaTime) - FMath::Sin(RunningTime));
NewLocation.Z += DeltaHeight * 20.0f; //Scale our height by a factor of 20
float DeltaRotation = DeltaTime * 20.0f; //Rotate by 20 degrees per second
NewRotation.Yaw += DeltaRotation;
SetActorLocationAndRotation(NewLocation, NewRotation);

The word “Tick” after the word “Super” is marked red.

class MYPROJECT_API ARotatingCube : public AActor

// Sets default values for this actor’s properties
UStaticMeshComponent* VisualMesh;
// Called when the game starts or when spawned
virtual void BeginPlay() override;

// Called every frame
virtual void Tick(float DeltaTime) override;


the lines above are written in my header file. “GENERATED_BODY()” is marked red and the error message says something about
considering adding it to a hint file and that this declaration doesnt have a storage class or no type specifier.

Can someone please help me out here until I have the possibility to learn by myself again using the documentation etc.?

Can you show the full header file code for ARotatingCube?

Had the same problem, just add like GarnerP57 said:

#include "RotatingCube.h"
#include "Components/StaticMeshComponent.h"
#include "ConstructorHelpers.h"

in the .cpp file NOT in the .h file!!!

Edit: Oh if someone can explain why it need to be in the .cpp and not in the .h would be nice ^^

It is a good practice only to include what you use (IWYU) something that UE4 started doing in 4.15. The header file (.h) doesn’t need to include ConstructorHelpers.h in order to declare its functions and variables. The implementation file (.cpp) however needs those function declarations to call the function.

Whenever you change a header file it has to recompile all the classes that uses that header while if you change the implementation file it just has to compile that specific implementation file.

You can also get multiple definitions with the same name when including it in the header file.

I had the same problem, added the includes listed above and then the error indicators went away. As was expected, as described above, it built, errors notwithstanding BUT…

When I went to drag the FloatingCube (what my tutorial said it was) to the scene I got nothing - just a listing of “FloatingCube1” in the world outliner but no cube mesh…no idea why but perhaps it’s because I’m using 4.22.3 and not 4.24?

I’m curious why the Unreal Documentation doesn’t mention those defines. Is it because the Unreal devs enjoy to have people scratching their heads? I mean the tutorial is called “Quick Start”.

I also find it quite fascinating how every responder is behaving like OP just happened to write it poorly on his own, chastising him on his poor programming practices. I mean he literally said:* “I was reading this quick guide: and followed step by step”*. What is going on here?