Advertisement

Annoying warning: 'x' intialized after 'y'

Started by April 16, 2005 11:40 PM
9 comments, last by Sharlin 19 years, 7 months ago
But as Qoy said, the members *will* be initialized in the right order, even when you write the list in a wrong order; g++ will automatically rearrange the list:
sharlin@pleco:~$ cat foo.cpp && g++ foo.cpp -o foo && ./foo#include <iostream>struct foo { foo(int i) { std::cout<<i<<'\n'; } };struct bar { bar() : f2(2), f1(1) { } foo f1, f2; };int main(){  bar b;}12

Of course, I'm not saying that ignoring warnings in general is a good thing, but in this case it shouldn't matter too much.

This topic is closed to new replies.

Advertisement