#include <string>
#include <iostream>
using FString = std::string;
class APawn
{
FString Name;
public:
APawn() : Name("Pawn"){};
void SetName(FString InName) { Name = InName; }
FString GetName() { return Name; }
};
class ATank : public APawn
{
public:
ATank() { SetName("Tank"); }
void AimAt() { std::cout << "Aiming" << std::endl; }
};
class ATankPlayerController
{
APawn* Pawn;
public:
ATankPlayerController(APawn* InPawn) { Pawn = InPawn; }
APawn* GetPawn() { return Pawn; }
};
int main()
{
ATank Tank;
ATankPlayerController TankPlayerController(&Tank);
std::cout << TankPlayerController.GetPawn()->GetName() << std::endl;
//TankPlayerController.GetPawn()->AimAt(); //error APawn doesn't have AimAt member
}
I2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBGU3RyaW5nID0gc3RkOjpzdHJpbmc7CmNsYXNzIEFQYXduIAp7CglGU3RyaW5nIE5hbWU7CnB1YmxpYzoKCUFQYXduKCkgOiAgTmFtZSgiUGF3biIpe307Cgl2b2lkIFNldE5hbWUoRlN0cmluZyBJbk5hbWUpIHsgTmFtZSA9IEluTmFtZTsgfQoJRlN0cmluZyBHZXROYW1lKCkgeyByZXR1cm4gTmFtZTsgfQp9OwpjbGFzcyBBVGFuayA6IHB1YmxpYyBBUGF3bgp7CnB1YmxpYzoKCUFUYW5rKCkgeyBTZXROYW1lKCJUYW5rIik7IH0KCXZvaWQgQWltQXQoKSB7IHN0ZDo6Y291dCA8PCAiQWltaW5nIiA8PCBzdGQ6OmVuZGw7IH0KfTsKCgpjbGFzcyBBVGFua1BsYXllckNvbnRyb2xsZXIKewoJQVBhd24qIFBhd247CnB1YmxpYzoKCUFUYW5rUGxheWVyQ29udHJvbGxlcihBUGF3biogSW5QYXduKSB7IFBhd24gPSBJblBhd247IH0KCUFQYXduKiBHZXRQYXduKCkgeyByZXR1cm4gUGF3bjsgfQp9OwoKaW50IG1haW4oKQp7CglBVGFuayBUYW5rOwoJQVRhbmtQbGF5ZXJDb250cm9sbGVyIFRhbmtQbGF5ZXJDb250cm9sbGVyKCZUYW5rKTsKCXN0ZDo6Y291dCA8PCBUYW5rUGxheWVyQ29udHJvbGxlci5HZXRQYXduKCktPkdldE5hbWUoKSA8PCBzdGQ6OmVuZGw7CgkvL1RhbmtQbGF5ZXJDb250cm9sbGVyLkdldFBhd24oKS0+QWltQXQoKTsgLy9lcnJvciBBUGF3biBkb2Vzbid0IGhhdmUgQWltQXQgbWVtYmVyCn0=