Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Order of member initialization
Re: Order of member initialization [message #58898 is a reply to message #58897] Fri, 23 September 2022 01:22 Go to previous messageGo to previous message
jjacksonRIAB is currently offline  jjacksonRIAB
Messages: 220
Registered: June 2011
Experienced Member
peterh wrote on Fri, 23 September 2022 01:13
I do not know these constructs, sorry.
Is this similar to pascals "with"?:
with a do begin
 b=1;
 c=2;
 d=3;
end;
Anyway this is too advanced for me I would not write this and I have nowhere read this until now. ;-/


It's a kindof newish feature called designated initializers. If you have a struct

struct a {
  int b {};
  int c {};
  int d {};
};


before these initializers you'd have to bracket initialize it as

a = { 1, 2, 3 };


but now you can use the member names.

a = { .b = 1, .c = 2, .d = 3 };


so it looks a bit cleaner. I haven't programmed Pascal in a considerable amount of time but I'm assuming the keyword 'with' enters the scope which is very similar but likely more powerful.

[Updated on: Fri, 23 September 2022 01:39]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Can TheIDE be used in two instances?
Next Topic: Some Questions
Goto Forum:
  


Current Time: Thu May 09 00:58:10 CEST 2024

Total time taken to generate the page: 0.02642 seconds