Events from base class to main class

Hi All,

I have a class inheriting from AActor, this class is kind of a base class say “MyBaseClass” for other to inherit from.

I also have a second class say “MainClass” inheriting from “MyBaseClass”

I’m wanting to have an event triggered in “MyBaseClass” and picked up from “MainClass”.

I’ve tried several ways of doing this, but, I’m just not understanding something relating to Events within C++

Note: This is all in C++ not calling from Blueprints.

Thanks

What exactly going wrong?

Hi,
I don’t know if I got your question correctly but I would simply implement the method you would like to execute in your “MyBaseClass”.
So, whenever your new event gets triggered within your “MainClass” you call the inherited function.

I did this using the following

in the base class
.h file

UFUNCTION(BlueprintNativeEvent, Category = "My Events")
void OnReceiveData(const TArray<uint8>& receiveddata);
virtual void OnReceiveData_Implementation(const TArray<uint8>& receiveddata);

.cpp

//Virtual Implementation
void ANDGSocket::OnReceiveData_Implementation(const TArray<uint8>& receiveddata)
{
	//This is left blank
}

In the inherited class

.h

virtual void OnReceiveData_Implementation(const TArray<uint8>& receiveddata) override;

.cpp

void ALoginSocket::OnReceiveData_Implementation(const TArray<uint8>& receiveddata)
{
   //Code goes here
}

This has worked for me so I thought I would share.
Hope it helps someone.