Consider:
struct A {
int i;
int j;
A() : j(0), i(j) { }
};
Now i
is initialized to some unknown value, not zero.
Alternatively, the initialization of i
may have some side effects for which the order is important. E.g.
A(int n) : j(n++), i(n++) { }
More Related Contents:
- g++ How to get warning on ignoring function return value
- Why should I initialize member variables in the order they’re declared in?
- Understanding -Weffc++
- Can I make GCC warn on passing too-wide types to functions?
- Why does flowing off the end of a non-void function without returning a value not produce a compiler error?
- to_string is not a member of std, says g++ (mingw)
- C++11 make_pair with specified template parameters doesn’t compile
- Selectively disable GCC warnings for only part of a translation unit
- Tail recursion in C++
- VSCode c++ task.json include path and libraries
- Why does typeid.name() return weird characters using GCC and how to make it print unmangled names?
- Static Data Member Initialization
- DSO missing from command line [duplicate]
- gcc/g++: “No such file or directory”
- C++ templates, undefined reference
- openCV program compile error “libopencv_core.so.2.4: cannot open shared object file: No such file or directory” in ubuntu 12.04
- g++ does not show a ‘unused’ warning
- How to tell where a header file is included from?
- Compilation error: “stddef.h: No such file or directory”
- How to include omp.h in OS X?
- Standard-layout and tail padding
- GNU C++ how to check when -std=c++0x is in effect?
- How to use profile guided optimizations in g++?
- How to compile C++ with C++11 support in Mac Terminal
- How to produce deterministic binary output with g++?
- Does the restrict keyword provide significant benefits in gcc/g++?
- std::enable_if : parameter vs template parameter
- g++ -Wall not warning about double-> int cast
- Can you really have a function/method without a body but just a try/catch block?
- Why “not all control paths return a value” is warning and not an error?