New error in 4.8 -- C2512: no appropriate default constructor available

I have a class derived from AActor and it contains a member that does not have a default constructor, i.e.:

#include "GameFramework/Actor.h"
#include "MyActor.generated.h"

UCLASS()
class MYGAME_API AMyActor : public AActor
{
    GENERATED_BODY()

public:

    AMyActor();

    some_other_class x;  // some_other_class has no default constructor!
};

But I initialize “x” accordingly in the CPP file:

#include "MyGame.h"
#include "MyActor.h"

AMyActor::AMyActor() :
    x(0, 0, 0) // must pass parameters to some_other_class constructor
{
    // Initialize AMyActor...
}

This worked as it should in 4.7 but in 4.8 I’m getting this error:

1>C:\Projects\MyGame\Intermediate\Build\Win64\UE4Editor\Inc\MyGame\MyGame.generated.cpp(502):
error C2512: ‘some_other_class’ : no
appropriate default constructor
available

The problem line in the generated code is this:

DEFINE_VTABLE_PTR_HELPER_CTOR(AMyActor);

Hello, Pat-Level17

I am sorry to hear about your problem.
Please note that in 4.8 the way virtual pointers are obtained for UClasses was changed, so that special empty constructor is used to get it. Special virtual table helper constructor is generated automatically for most cases, but sometimes it’s not possible (for example when there is no default constructor for members types).
In this situation, there is a possibility to override the generated constructor and write a custom one like this:

UCustomClass::UCustomClass(FVTableHelper& Helper)

(Constructor of the base class needs to be called with the same parameter.)

Please note that this constructor should not be used for anything else since there is no guarantee the object will be in correct state after calling it.

Thus, to fix the problem, you can add something like this to your code:

AMyActor(FVTableHelper& Helper)
     : Super(Helper),
       x(0, 0, 0) 
    {
    }

Hope this helped!

Cheers!

That fixes it. Thank you.

This is kind of an awkward thing to have to do, but it works.