Exception_access_violation

I want to add the pointer of PlayerController Class that inherits UInterface Class into TArray<UInterfaceClass*>. But here is the error Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x00000000000002f8.

Here is my source below.

// This class does not need to be modified.
UINTERFACE(MinimalAPI)
class UMatchMakingTicket : public UInterface
{
	GENERATED_BODY()
};

class RM_API IMatchMakingTicket
{
	GENERATED_BODY()
	// Add interface functions to this class. This is the class that will be inherited to implement this interface.
public:
	virtual FString GetTicketId() = 0;

	virtual int GetPoint() = 0;

	virtual void OnMatched(FName SessionName) = 0;
};

class RM_API APenaltyShootOutPlayerController : public APlayerController, public IMatchMakingTicket
{
...
   /*
	* IMatchMakingTicket
	*/
	virtual FString GetTicketId() override;

	virtual int GetPoint() override;

	virtual void OnMatched(FName SessionName) override;
...
}
TArray<IMatchMakingTicket*> Tickets;
APenaltyShootOutPlayerController* playerController = ...
Tickets.Add(playerController); // <- EXCEPTION_ACCESS_VIOLATION 

How can i solve the error?

If you want to add an item to IMatchMakingTicket* array, that item must be of IMatchMakingTicket class.

Your player controller does not inherit from your interface, it only implements it. Only the first class after : is inheritance. So you can create an array of APlayerController* and add your custom controller to it, but it doesn’t work with interfaces.

You simply need to Cast to your interface class first:
Tickets.Add(Cast<IMatchMakingTicket>(playerController));

Thanks but it doesn’t work. The same error still happens.

== Edit ==
Sorry my mistake. It works. Thanks a lot!