3

The style of code using designated initializers below belongs to C language

 int widths[] = { [0] = 1, [10] = 2, [100] = 3 };

I would like to know, is there some way to write such a simple code in C++?

Vlad from Moscow
  • 265,791
  • 20
  • 170
  • 303
Vladyslav Nikolaiev
  • 1,622
  • 3
  • 17
  • 35

1 Answers1

3

In C++ you have to write

int widths[101] = { 1 };
widths[10]  = 2;
widths[100] = 3;
Vlad from Moscow
  • 265,791
  • 20
  • 170
  • 303