On Monday, 7 May 2012 at 18:03:45 UTC, Chris Cain wrote:
On Monday, 7 May 2012 at 17:52:01 UTC, ixid wrote:
Thank you, could you explain what is happening in your example? Bar is inheriting from Foo, what are you getting when you create a parent of type sub-class compared to Bar b = new Bar; and Foo b = new Foo; ? Foo b = new Bar won't compile if you add members to Bar and access them.

Foo is the "interface" you'll have to bar.

OOP isn't terribly hard, but I suggest reading up on it some to grasp the concepts (and especially so you can see the benefits).

D also takes the approach with classes and objects that is closer to java than C++: All methods are overridable for polymorphism by default. Using interfaces and safely up&down casting using the known interfaces is so much easier. I haven't done much with C++, but these types of things are more error and bug prone than D and java; Not to mention the STL gives me a total headache.

I have a good mental idea of how to explain OOP and inheritance using a RPG-like game example, which would be less confusing than the usual animals and shapes (At least it is to me).

Reply via email to