Delegate events does't work?

The event is declared in class A, and the event object function BroadCast is called in class B and it still works! This violates the design rules of the incident? Is it my operation problem?

I will use this space because it is easy to add code, but I actually have a question for you. You are saying that you have class A, lets say the following (this cames from here):

public:
/** Broadcasts whenever the layer changes */
DECLARE_EVENT( FLayerViewModel, FChangedEvent )
FChangedEvent& OnChanged() { return ChangedEvent; }

protected:
void BroadcastChanged()
{
    ChangedEvent.Broadcast();
}

private:
/** Broadcasts whenever the layer changes */
FChangedEvent ChangedEvent;

In this particular case you can see that there is no way to call Broadcast from a this class or any class that Inherits from it right?

Now, suppose you make FChangedEvent ChangedEvent; public. With this setup are you saying that from your class B you can call the broadcast method?

class B
{
public:
MyClass A;

void Method() 
{
   A.ChangedEvent.Broadcast();
}

};

Is that what you are saying? If so then yes, I can’t see a reason for this not to work. The event still belongs to class A and it is being called by class A.

hi mcleary
thanks for your answer. I think it may be that I made a mistake. I think the official explanation is that in class A, you can only call the Broadcast function inside class A. The Broadcast function can still be executed in Class B by calling the function OnChanged. Is this allowed?

I can’t see a reason why not. Note that this is not the same as delegates. Delegates can be passed around and called by any class.

thanks mcleary,I read the source code and found that the designer wanted to use friend to complete the design, but the key functions were set to public access, which is very strange