Run-time reflection for class inheritance
Adam D. Ruppe
destructionator at gmail.com
Sun Dec 1 14:42:46 UTC 2019
On Sunday, 1 December 2019 at 12:26:03 UTC, Michael Green wrote:
> I don't know if this would be a sensible approach to try and
> get at the actual class types for objects stored in some
> container at runtime?
You can get the type at runtime by simply casting it...
if(auto c = cast(EventSocket) event) {
// is an event socket
}
and then you can actually use the c object too.
Or if you put the necessary functionality in the interface then
you simply call the method - this is better object-oriented
design as it reduces the necessary knowledge for the function to
use the object.
More information about the Digitalmars-d-learn
mailing list