Problem using Interfce
H. S. Teoh
hsteoh at quickfur.ath.cx
Tue May 15 20:08:44 PDT 2012
On Wed, May 16, 2012 at 04:24:12AM +0200, Stephen Jones wrote:
[...]
> Thanks Ali for the syntax, some very useful bits and pieces I did
> not know. I do not want to use property syntax. Form a performance
> perspective I cannot see any good reason not to simply use an array
> of pointers to the different objects (buttons, cursor, etc) rather
> than incurring function overheads. Except for the good reason that I
> do not know the syntax.
>
> Ary: I seem to remember playing around with a Simpsons extending
> program in Java that did this; you could throw all the different
> Simpsons into a single Array because they extended "Simpson", and
> you could walk through the array and each would call their own name.
> I kind of purposely left the language vague in case I was mistaken.
Here:
class Simpson {
string name;
}
class Bart : Simpson {
this() {
name = "Bart Simpson";
}
}
class Homer : Simpson {
this() {
name = "Homer Simpson";
}
}
void main() {
Simpson[] simpsons;
foreach (simpson; simpsons) {
writeln(simson.name);
}
}
T
--
PNP = Plug 'N' Pray
More information about the Digitalmars-d-learn
mailing list