621
|
1 // $HeadURL$
|
|
2 // $Date$
|
|
3 // $Author$
|
|
4
|
|
5 // @author@ xs0 <xs0@xs0.com>
|
|
6 // @date@ 2005-08-11
|
|
7 // @uri@ news:ddfegl$2uof$1@digitaldaemon.com
|
|
8
|
|
9 //
|
|
10 // http://www.digitalmars.com/d/attribute.html
|
|
11 //
|
|
12 // (1)
|
|
13 // The const attribute declares constants that can be evaluated at
|
|
14 // compile time.
|
|
15 //
|
|
16 // (2)
|
|
17 // A const declaration without an initializer must be initialized in a
|
|
18 // constructor (for class fields) or in a static constructor (for static
|
|
19 // class members, or module variable declarations).
|
|
20 //
|
|
21
|
|
22 module dstress.undefined.const_24;
|
|
23
|
|
24 class Class{
|
|
25 const int i;
|
|
26
|
|
27 this(){
|
|
28 i=dynamicInt; // illegal(1) or legal(2) ?
|
|
29 }
|
|
30 }
|
|
31
|
|
32 int dynamicInt;
|
|
33
|
|
34 int main(char[][] args){
|
|
35 dynamicInt=args.length;
|
|
36
|
|
37 Class c = new Class();
|
|
38 assert(c.i==args.length);
|
|
39
|
|
40 return 0;
|
|
41 } |