Yes. It’s safe to use this
pointer in initialization-list as long as it’s not being used to access uninitialized members or virtual functions, directly or indirectly, as the object is not yet fully constructed. The object child
can store the this
pointer of Parent
for later use!
More Related Contents:
- C++ cannot initialize static data member [duplicate]
- Do the parentheses after the type name make a difference with new?
- How to initialize private static members in C++?
- Why is list initialization (using curly braces) better than the alternatives?
- What is the easiest way to initialize a std::vector with hardcoded elements?
- Array[n] vs Array[10] – Initializing array with variable vs numeric literal
- Finding C++ static initialization order problems
- Uninitialized variable behaviour in C++
- static initialization order fiasco
- If a function returns no value, with a valid return type, is it okay to for the compiler to return garbage?
- When are static C++ class members initialized?
- What is the ‘this’ pointer?
- How to initialise memory with new operator in C++?
- Object creation on the stack/heap?
- Using newly declared variable in initialization (int x = x+1)?
- C++11: Correct std::array initialization?
- What are primitive types default-initialized to in C++?
- Now that we have std::array what uses are left for C-style arrays?
- C++: Where to initialize variables in constructor [duplicate]
- How can I make `new[]` default-initialize the array of primitive types?
- How to do the equivalent of memset(this, …) without clobbering the vtbl?
- How are local and global variables initialized by default?
- Different ways of initializing an object in c++
- How could comma separated initialization such as in Eigen be possibly implemented in C++?
- Initialization difference with or without curly braces in C++
- Is uninitialized data behavior well specified?
- C++ function called without object initialization
- What does ‘return *this’ mean in C++?
- C++ – value of uninitialized vector
- C++ default initialization and value initialization: which is which, which is called when and how to reliably initialize a template-type member