{ int a; };
struct B : public A { int b; };
B b{.A={.a=1}, .b=2};
C++20 supports designated initializers
Yes I know but they use initializer lists aka constructors
I want something like B{:A{.a=1}, .b=2} to be valid.
Nesting isn't valid in initializers as they are now in C++ iirc
if you don
Well if you don't want to define a constructor, you'll probably have to use mixture of designated and non-designated initializers in the same initializer list which is ugly imo but \(_-_)/
Обсуждают сегодня