Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22288

What is the order of evaluation in a member initializer list?

$
0
0

I have a constructor that takes some arguments. I had assumed that they were initialized in the order listed, but in one case, it appears they were being initialized in reverse, resulting in an abort. When I reversed the arguments, the program stopped aborting.

Below is an example of the syntax I'm using. a_ needs to be initialized before b_ in this case. Can you ensure this order of initialization?

class A{  public:    OtherClass a_;    AnotherClass b_;    A(OtherClass o, string x, int y)      : a_(o)      , b_(a_, x, y) {}};

Viewing all articles
Browse latest Browse all 22288

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>