Ето как би станало на Delphi.. но имам една забележка, следващия път бъди малко по подробен защото в първия момент не можах да те разбера, поне един кометар да беше сложил, a и имаше една грешка m_pComponent->pOwner = this; май трябва да е m_pComponent->m_pOwner = this; но това е без значение :)))
unit Unit2;
interface
type
CThisInstanceOwner = class
procedure NotifyOwner; virtual; abstract;
end;
CEmbededComponent = class
public
m_pOwner: CThisInstanceOwner;
procedure ClassStatusChanged;
end;
COwner = class(CThisInstanceOwner)
public
m_pComponent: CEmbededComponent;
constructor Create;
procedure NotifyOwner;
end;
implementation
uses Windows;
{ CEmbededComponent }
procedure CEmbededComponent.ClassStatusChanged;
begin
m_pOwner.NotifyOwner;
end;
{ COwner }
constructor COwner.Create;
begin
m_pComponent := CEmbededComponent.Create;
m_pComponent.m_pOwner := Self;
end;
procedure COwner.NotifyOwner;
begin
MessageBox(0, 'Owner is notified!', 'Caption', MB_OK);
end;
end.