Class methods in D?
Mehrdad
wfunction at hotmail.com
Thu May 3 10:48:24 PDT 2012
On Thursday, 3 May 2012 at 17:45:20 UTC, Steven Schveighoffer
wrote:
> This works:
>
> import std.stdio;
>
> class A
> {
> string name;
> this() {this.name = typeid(this).name;}
> }
>
> class B : A {}
>
> void main()
> {
> A b = new B;
> A a = new A;
> writefln("A: %s, B: %s", a.name, b.name);
> }
>
> outputs:
>
> A: testclassname.A, B: testclassname.B
>
> -Steve
Oh, but that's only the name!
The trouble is that window classes have a lot of attributes --
styles, background brushes, etc. -- that are all shared across
instances.
There is currently no way (that I know of) to allow a subclass to
define its own attributes, *without* also giving it a chance to
define them per-instance instead of per-class.
More information about the Digitalmars-d
mailing list