I want to define a method in my class but that method should be implemented by the instance.
I think this is a virtual function in C++

Does one do this with event definitions in Xojo?
If so how does one raise that event on the instance of the class?

You want pure virtual so subs MUST implement it ?

I believe you understand me Norman.

I can think of a couple ways you might do this

  1. an interface but this can be implemented by any class not strictly subclasses. This may / may not be useful.
    The compiler can catch if anything is missing

  2. a base class with the method implemented but have the base class implementation raise an exception
    The practical effect is that subs MUST override it but you don’t find this out until runtime

Now what you could do is combine these and define an interface (for general use) and then write an initial base class that implements that interface. The methods the subclasses MUST override raise an exception if they are not overridden.

Events are not QUITE the same although I have seen people use them this way like a dispatch mechanism for calling down class hierarchy.
It means you create base class that has a method whose sole purpose is to raise an event that then gets passed down from super to subs. So you have lots of defining the same event over & over to pass it down & lots of event handlers.

And theres no way to really say a sub MUST implement it
It CAN but the super doesn’t know if it has or not