I know it may seems a very noob question, But really I spent a lot of hours to find out what and when I use Super class
there is examples I Could understand such as Super::BeginPlay();
but what I couldn’t understand why we used it like so Super::PostInitProperties(); or Super::PostEditChangeProperty()
however there is no problem with me understanding the API itself, But still “Super” can’t understand it’s specific use exactly .or what does it mean?
If you have a BaseClass where you defined a virtual function and gave it some logic, and you create a child class from it where you override this functions, you can make sure that the BaseClass code is still called by calling “Super::Function()”.
void AClassSample::BeginPlay()
{
Super::BeginPlay(); // we call default begin play from Super class
// But for what? Default Begin Play Function contains
// Some methods, that are neccessarry to execute it as
// actually BeginPlay function. but when we override it,
// all the functionality of default BeginPlay disappears.
// Because of overriding, we need at first to call default
// BeginPlay function, to include default function logic,
// and then do the rest of things.
}
void AClassSample::BeginPlay()
{
Super::BeginPlay(); // we call default begin play from Super class
// But for what? Default Begin Play Function contains
// Some methods, that are neccessarry to execute it as
// actually BeginPlay function. but when we override it,
// all the functionality of default BeginPlay disappears.
// Because of overriding, we need at first to call default
// BeginPlay function, to include default function logic
// from Super class, and then do the rest of things.
}
Good followup - as the accepted answer described what super is generically in programming, but doesn’t exist in standard c++ because of multiple inheritance ambiguity. Hence OP’s long fruitless search.
A macrofied class system like UE has can however safely mimic it with a typedef.
Because in some cases we want to allow the engine to do a lot of things and to follow its logical flow.
Two messages above yours, NkIceberg went through explaining Super::BeginPlay() as an example.
and then I start up my game and try to spawn a child class?
Will the ChildClass’s Super::Tick(DeltaTime) reach the Base AActor class from the child class, or will it stop in the ParentClass::Tick and break?
What if I then call
InstanceOfChildClass->NonUeFunction(3)
Will both child and parent NonUeFuncitons work because we get the use of Super with the UCLASS() decorator or something? Or will it break because “Super” is only manually set in Unreal Source classes?