C++ Casting ACharacter child pointer to AActor* does not work

I’ve got custom c++ class that’s a child of ACharacter class, so:

AActor → APawn → ACharacter →

When I try to cast AMyClass pointer to AActor pointer I get an error:

// header file
UPROPERTY(BlueprintReadWrite) class AMyClass * A;

// cpp file
AActor * B = A; // error

a value of type “AMyClass *” cannot be used to initialize an entity of type “AActor *”

What am I doing wrong? With normal, empty C++ classes it works.

Hey! You are not actually casting the variable
Try using:

AActor* B = Cast<AActor>(A);

This should work!

Yup it works, thank you!
I also found out that it works when I cast it like this

AActor * B = (AActor*) A;

Your way looks more clean tho.