The problem of multiple inheritance and getting components

UE4 has the relationship that UCharacter inherits APawn and APawn inherits AActor. However, I found that the engine code did not use virtual inheritance, and I tried to use multiple inheritance but failed to compile. And we can’t modify the AActor code directly. If I want to add some new function to AActor or modify some existing functions, I must create a new class MyActor and add or overload functions.

However, I can’t make this modification of my MyActor be inherited by MyPawn and MyCharacter I created, unless I give up my MyPawn inheriting APawn and MyCharacter inheriting UCharacter. This makes the class MyActor I made to modify AActor have to be done again on MyPawn and MyCharacter. Once the modification is involved, the three classes may be inconsistent.

So I thought of making a component class MyComponent, and adding it to three classes. But because I can’t directly modify aactor’s code, I can’t write code like this:

AActor* Object;

Objcet->MyComponent->MyFunction();

The reason why I can’t write such code is simple, because AActor doesn’t have MyComponent at all.
So why should I write this code? Because I want the pointer to point to MyActor, MyPawn, MyCharacter. In order to use the function of engine class, MyPawn inherits APawn and MyCharacter inherits UCharacter, so only AActor pointer can point to these three class of objects. But the AActor pointer has no MyComponent.

Why not use this * because the formal parameter of the function may be another object. For example, the function is used to calculate the distance between two players - although UE4 has this function, this is just an example.

So what can be done to solve this problem?