- C++20 Designated initializers + struct member initializer - 6 Updates
- Bollocks! - 1 Update
- T const - 1 Update
Pankaj Jangid <pankaj.jangid@gmail.com>: Nov 08 03:17PM +0530 > .pt1 = {.name='pt1' .x=1 .y=2} .pt1 = {.name='' .x=3 .y=2} > I was expecting this for the last print: > .pt1 = {.name='pt1' .x=3 .y=2} It is like this, struct Point pt1 = {.x = 3} printf(".pt1 = {.name='%s' .x=%d .y=%d}\n", pt1.name, pt1.x, pt1.y); struct Line line2 = {.pt1 = pt1} printf(".pt1 = {.name='%s' .x=%d .y=%d}\n", line2.pt1.name, line2.pt1.x, line2.pt1.y); Should the first and the second printf statement print different output? |
"Christian Hanné" <the.hanne@gmail.com>: Nov 08 07:18PM +0100 Designated initializers aren't needed. There are constructors. |
Ian Collins <ian-news@hotmail.com>: Nov 09 08:12AM +1300 On 09/11/2020 07:18, Christian Hanné wrote: > Designated initializers aren't needed. There are constructors. Not for C structs used in C++ code there aren't... -- Ian. |
"Christian Hanné" <the.hanne@gmail.com>: Nov 08 08:13PM +0100 >> Designated initializers aren't needed. There are constructors. > Not for C structs used in C++ code there aren't... Then you derive a C++-class from the C-struct with a constructor. |
Ian Collins <ian-news@hotmail.com>: Nov 09 08:40AM +1300 On 09/11/2020 08:13, Christian Hanné wrote: >>> Designated initializers aren't needed. There are constructors. >> Not for C structs used in C++ code there aren't... > Then you derive a C++-class from the C-struct with a constructor. For simple cases that's fine, but it can get messy fast when there are multiple structs and different fields require initialisation in different contexts (Linux USB for example). I have resorted to mixing C and C++ TUs to work around the lack of designated initialisers in C++. -- Ian. |
Keith Thompson <Keith.S.Thompson+u@gmail.com>: Nov 08 01:27PM -0800 > Designated initializers aren't needed. There are constructors. Loops aren't needed. There are gotos. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com Working, but not speaking, for Philips Healthcare void Void(void) { Void(); } /* The recursive call of the void */ |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Nov 08 06:12PM https://www.youtube.com/watch?v=JaY7VTftPdY Bollocks! -- ¬ |
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Nov 08 07:58AM +0100 On 07.11.2020 21:41, Mr Flibble wrote: >> const auto& s = "Aha"; >> ... which is shorter and preserves the string length information. > Alf, pack this fucking nonsense in, pls. At times, when sausages or negativity are on your mind, it's like these ideas prevent ordinary thinking, reducing you. - Alf |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment