June 02, 2004 classes in functions | ||||
---|---|---|---|---|
| ||||
the following code: ------------------------------------------ void f1() { class foo { } } void f2() { class foo { public int a; } foo x = new foo; x.a = 0; } void main() { f1(); f2(); } ------------------------------------------ causes an error: no property 'a' for type 'foo' if the definition of class foo in function f1 is removed, there's no error. seems like classes defined in functions were put to a global scope but without any redefinition errors and yet this isnt possible: void f1() { class foo { public int a; } } void f2() { foo x = new foo; x.a = 0; } void main() { f1(); f2(); } hope this helps |
Copyright © 1999-2021 by the D Language Foundation