C++ Logo

STD-DISCUSSION

Advanced search

Subject: Fwd: Parent pointer to access the parent class from member
From: Hanspeter Bieri-Ineichen (bieri.hp_at_[hidden])
Date: 2020-06-28 17:17:48


The important ability of C/C++ that classes can be direct members of a
class allows to access them by a this-pointer offset instead of a pointer
derefenciation.

To access the parent class from a member the usual way is to store a
pointer to the parent. There no simple way that uses the member offset. A
template solution is shown here:
https://stackoverflow.com/questions/62103638/access-parent-class-from-member-without-storing-pointer-of-parent

Would it be useful to have something like a parent pointer similar to the
this-pointer?



STD-DISCUSSION list run by herb.sutter at gmail.com

Older Archives on Google Groups