I keep getting the -Wreorder error, saying "willl be initialized after", but it's very strange, because I have two variables, int width, height; Then in the initialization list I do : width(col_width), height(col_height), and I get a warning saying "warning: ‘FixedGridLayout::height’ will be initialized after [-Wreorder] int width, height;"
Which obviously my initialization is in the exact same order that the variables are defined, height SHOULD be initialized after, so why is it warning me??? And even if I switch it, then it says "warning: ‘FixedGridLayout::width’ will be initialized after [-Wreorder] int width, height;"
Which makes sense, but it's just frustrating that no matter what order I put them in it gives me this warning! I know it's not a big deal, it's just a warning, but it's very frustrating and it's driving me OCD :P
P.S. I know a similar question has been asked, but this question is NOT a duplicate, because the other questions were based on the fact that the asker had the initialization list in the wrong order, while MY question is based on the fact that the order of initialization doesn't make a difference. So please do not mark this as a duplicate ;)
Never mind, I figured it out, this was one of those times where the actual issue wasn't in the warning/error message. I also had a base class being initialized, and that is what was actually causing the error.
I had this:
MyClass::MyClass(QWidget *parent, int col_width, int row_height)
: width(col_width), height(row_height), BaseClass(parent) {}
//^^^^^^^^^^ Here's the Problem!!!
What I needed was this:
MyClass::MyClass(QWidget *parent, int col_width, int row_height)
: BaseClass(parent), width(col_width), height(row_height) {}
It just threw me off, because the message was warning that height was initialized after, it didn't say anything about BaseClass, which was the actual problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With