Bug 4553 – D2 Language Docs: http://www.digitalmars.com/d/2.0/struct.html

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dlang.org
Product
D
Version
D2
Platform
Other
OS
All
Creation time
2010-08-01T10:43:00Z
Last change time
2012-01-15T14:14:56Z
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2010-08-01T10:43:56Z
"Static Initialization of Structs" There is inconsistency between the examples. Replace X with S in all the examples. In the 4th example, this line: S s = { 1, i }; // q.a = 1, q.b = i, q.c = 0, q.d = 7 Should be replaced with: S q = { 1, i }; // q.a = 1, q.b = i, q.c = 0, q.d = 7 "Const and Invariant Structs" In the code example the statement t = s; is not compilable: const struct S { int a; int b = 2; } void main() { S s = S(3); // initializes s.a to 3 S t; // initializes t.a to 0 t = s; // ok, t.a is now 3 //~ t.a = 4; // error, t.a is const } test3.d(29): Error: variable test3.main.t cannot modify const "Struct Constructors" There are no code examples here. A simple one could be added: struct S { int x; int y; this (int x_val, int y_val) { x = x_val; y = y_val; } } void main() { S s = S(4, 5); }
Comment #1 by bugzilla — 2012-01-15T14:14:56Z