Delegate Scope confusion with C++ function

MarvinECL
Fri, 10 Mar 2023 08:49:03 +0000
C++

I’m confused of the correct scope of delegate in C++. Here is an example:

I made an delegate declearation : DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnStart)

And I let the object A hold the delegate: A { ... FOnStart OnStart ... };

And instead of call member function directly, I bind member function of A to the delegate, and brocast the delegate.

void UObjectA::Start()
{
	this->OnStart.AddDynamic(this, &UObjectA::Then);
	this->OnStart.Broadcast();
}

So when the function Then() is started, is function Start() already finished? Or the program is still in scope of function Start()? I read the documentation of delegates, and I assume it is some kind of function pointer. But I still need to confirm this assumption.

3 posts - 3 participants