Hi

Working with objectoriented concepts results often in large trees of related classes. Every instance of a class knows his methods and data. An example like following would work:

import std.stdio;
class Family { }
class Dad : Family { void greeting() { writeln("I'm dad"); } }
class Boy : Family { void greeting() { writeln("I'm daddy's boy"); } }
void main() {
writeln("Father and son");
Dad father = new Dad;
Family son = new Boy;
father.greeting;
son.greeting;
}

The critical point is using a variable of type Family for an instance of Boy. Class Family covers the greeting method of Boy. In real OOP that would not be a problem, because the access point of view starts with the object. In D, it starts with the class definition.

Is there any way to get real OOP with D?

Regards,  Ozan

Reply via email to