Похожие чаты

Does anyone know the correct syntax for doing this? struct A

{ int a; };
struct B : public A { int b; };
B b{.A={.a=1}, .b=2};

7 ответов

21 просмотр

AFAIK it .named intializer format is only directly valid in C so in C++ it uses intializer lists, so you need to match the constructor input to get that to work. So like your professor or that rude guy in another grp might have said, always define constructors...

Stanislav Ershov
C++20 supports designated initializers

Yes I know but they use initializer lists aka constructors

BSP- Автор вопроса

I want something like B{:A{.a=1}, .b=2} to be valid.

BSP
I want something like B{:A{.a=1}, .b=2} to be vali...

Nesting isn't valid in initializers as they are now in C++ iirc

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 \(_-_)/

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта