Classes (does this make sense?)

Saaa empty at needmail.com
Mon Jun 2 17:31:05 PDT 2008


Thanks, I changed it to this (I think I get it now :)
Any comments are of course still appreciated ;)

-----------------------
module main;

import std.stdio;
import apple;

abstract class IFruit
{
int number;
void eat();
}

int main(string[] args) {
IFruit[] fruits = [new Apple(12), new Apple];
writefln("Fruits");
foreach( f; fruits) {
f.eat();
}
return 0;
}
------------------
module apple;

import std.stdio;
import main;

class Apple : IFruit {
void eat() {
writefln("Eat Apple");
}

this ()
{
}

this (uint color)
{
this.color=color;
}
}




More information about the Digitalmars-d-learn mailing list