Is it standard C++ to assign a member pointer to the address of another member in the constructor initializer?
-
03-10-2019 - |
문제
Does this conform to the standard?
class Foo {
Bar m_bar;
Bar * m_woo;
public:
Foo() : m_bar(42, 123), m_woo(&m_bar) { }
};
해결책
It is correct. What is not correct is dereferencing that pointer before that particular subobject has been fully initialized.
제휴하지 않습니다 StackOverflow