다음과 같이 Container
멤버를 초기화하려면 생성자의 멤버 초기화 목록에서 Container
객체에 대한 참조를 해당 생성자의 멤버 초기화 목록에 전달할 수 있습니까? : (코드는 ideone).생성자의 멤버 초기화 목록에있는 객체에 대한 참조 사용
#include <cstdlib>
#include <iostream>
struct Container;
struct Member
{
Member(Container& container) : m_container(container)
{
}
Container& m_container;
};
struct Container
{
Container() : m_member(*this)
{
}
Member m_member;
};
int main()
{
Container c;
return EXIT_SUCCESS;
}
코드가 컴파일되지만 표준인지 확실하지 않습니다.