Tutorial by Examples

To define the struct called Person with an integer type variable age, integer type variable height and float type variable ageXHeight: struct Person { int age; int height; float ageXHeight; } Generally: struct structName { /+ values go here +/ }
In D we can use constructors to initialize structs just like a class. To define a construct for the struct declared in the previous example we can type: struct Person { this(int age, int height) { this.age = age; this.height = height; this.ageXHeight = cast(float)age...

Page 1 of 1