Re: is Dlang support Uniform initialization like c++

2023-06-30 Thread Ali Çehreli via Digitalmars-d-learn
On 6/30/23 08:18, lili wrote: How too wirte this: addPoint({4,5}, {4,6}) In this case, arrays are better but only if you don't define a constructor, which you don't need for simple types like Point below: struct Point { int x; int y; } void main() { // The type is explicit on

Re: is Dlang support Uniform initialization like c++

2023-06-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/30/23 11:18 AM, lili wrote:     struct Point { int x; int y;   this(int x, int y) { this.x =x; this.y=y;}     }     void addPoint(Point a, Point b) {    ...     } How too wirte this: addPoint({4,5}, {4,6}) You have to write `Point(4, 5)`. The advantage is we

Re: is Dlang support Uniform initialization like c++

2023-06-30 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jun 30, 2023 at 03:18:41PM +, lili via Digitalmars-d-learn wrote: > struct Point { > int x; > int y; > this(int x, int y) { this.x =x; this.y=y;} > } > > void addPoint(Point a, Point b) { >... > } > > How too wirte this: addPoint({4,5}, {4,6})

is Dlang support Uniform initialization like c++

2023-06-30 Thread lili via Digitalmars-d-learn
struct Point { int x; int y; this(int x, int y) { this.x =x; this.y=y;} } void addPoint(Point a, Point b) { ... } How too wirte this: addPoint({4,5}, {4,6})