mercredi 15 avril 2020

C++11: How to get address / reference to outer class??

Suppose the following class (C++11):

class A
{
  int i;
  class B
  {
    void meth() 
    {
        // Get outer address / reference? 
    }; 
  } b;
};

where B will always be part of A, i.e. there is no code like new B().

This means b.meth() will always operate with an outer A.

Question: How get to outer from b.meth() (which has always the same offset to b and that's known at compile time)?

Aucun commentaire:

Enregistrer un commentaire