September 17, 2005 Protection attributes | ||||
---|---|---|---|---|
| ||||
(Original post at http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/28704) Protection attributes on module-level class, struct, interface, enum, template, alias and union delcarations (and possibly others) don't work. Also, some protection attributes don't work on any module-level declarations, eg constants. Test code: -prot.d- module prot; private interface IEngine { void start(); } private class Engine : IEngine { void start() { } } protected const int DEFAULT_SPOKES = 200; protected struct Wheel { int spokes; } -main.d- module main; import prot; int main() { Wheel wheel; wheel.spokes = DEFAULT_SPOKES; IEngine engine = new Engine; engine.start(); return 0; } |
September 20, 2005 Re: Protection attributes | ||||
---|---|---|---|---|
| ||||
Posted in reply to John C Attachments: | John C schrieb: > (Original post at http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/28704) > > Protection attributes on module-level class, struct, interface, enum, template, alias and union delcarations (and possibly others) don't work. Also, some protection attributes don't work on any module-level declarations, eg constants. > > Test code: > > -prot.d- > module prot; > > private interface IEngine { > void start(); > } > > private class Engine : IEngine { > void start() { > } > } Added to DStress as http://dstress.kuehne.cn/nocompile/pprivate_08_A.d http://dstress.kuehne.cn/nocompile/pprivate_08_B.d http://dstress.kuehne.cn/nocompile/pprivate_08_C.d http://dstress.kuehne.cn/nocompile/pprivate_08_D.d http://dstress.kuehne.cn/nocompile/pprivate_08_E.d http://dstress.kuehne.cn/nocompile/pprivate_08_F.d > protected const int DEFAULT_SPOKES = 200; > > protected struct Wheel { > int spokes; > } http://digitalmars.com/d/attribute.html # Protected module members are illegal. > > -main.d- > module main; > > import prot; > > int main() { > Wheel wheel; > wheel.spokes = DEFAULT_SPOKES; > IEngine engine = new Engine; > engine.start(); > > return 0; > } Thomas |
Copyright © 1999-2021 by the D Language Foundation