Can I pass a pointer to a derived-class field to the superconstructor if the superconstructor doesn't use that pointer?

StackOverflow https://stackoverflow.com/questions/20790007

문제

If I have a derived class, I know that the fields aren't instantiated yet when the superconstructor is called. But, can I pass a pointer to one such field (obtained with &field) to the superconstructor if I know that the superconstructor is not going to dereference the pointer?

Particularly, I want to know whether the call to &field will behave properly and point to the section of memory which will eventually contain that field.

도움이 되었습니까?

해결책

Yes, although actually doing this would be questionable at best.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top