Skip to content

Commit a75cb4b

Browse files
author
mikeblome
committed
updated aggregate initializers fixes user story 1203058
1 parent ff0437d commit a75cb4b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

docs/cpp/initializers.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,14 @@ struct MyAggregate{
379379
char myChar;
380380
};
381381
382+
struct MyAggregate2{
383+
int myInt;
384+
char myChar = 'Z'; // member-initializer OK in C++14
385+
};
386+
382387
int main() {
383388
MyAggregate agg1{ 1, 'c' };
384-
389+
MyAggregate2 agg2{2};
385390
cout << "agg1: " << agg1.myChar << ": " << agg1.myInt << endl;
386391
cout << "agg2: " << agg2.myChar << ": " << agg2.myInt << endl;
387392
@@ -407,7 +412,7 @@ You should see the following output:
407412

408413
```Output
409414
agg1: c: 1
410-
agg2: d: 2
415+
agg2: Z: 2
411416
myArr1: 1 2 3 4
412417
myArr3: 8 9 10 0 0
413418
```

0 commit comments

Comments
 (0)