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 #58889 is a reply to message #58886] Wed, 21 September 2022 19:00 Go to previous messageGo to previous message
jjacksonRIAB is currently offline  jjacksonRIAB
Messages: 220
Registered: June 2011
Experienced Member
peterh Quote:

I find this answer from stackoverflow very clear:

https://stackoverflow.com/questions/2517050/c-construction-a nd-initialization-order-guarantees

I hope it is correct.


with inherited classes, that's what I thought too (that it proceeded left to right), but I didn't check.

https://en.cppreference.com/w/cpp/language/eval_order

Looks like they call them sequence points and they proceed in order - here's initialization lists:

Quote:

10) In list-initialization, every value computation and side effect of a given initializer clause is sequenced before every value computation and side effect associated with any initializer clause that follows it in the brace-enclosed comma-separated list of initializers.


I should acquaint myself with this stuff better, a lot of things have been changing and what was formerly Undefined Behavior is being addressed. I just learned by accident a few months ago that in C++17 there is type inference now even for template types so you no longer have to write:

Vector<int>    x { 1, 2, 3 };
Vector<String> y { "hello", "world" };


you can just write:

Vector x { 1, 2, 3 };
Vector y { "hello", "world" };


and it will fill in the type for you.

[Updated on: Wed, 21 September 2022 19:53]

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: Wed May 08 11:22:09 CEST 2024

Total time taken to generate the page: 0.02006 seconds