How can I access class attribute from its nested class method?
class Class1
{
public:
int attribute;
void Method1() {
class Class2
{
public:
void Method2() {
//here I need to access attribute from Class1
}
};
}
};
thiseither as a method parameter or when constructingClass2.Class2::Method2(), you would need some global accessor funciton to find Class1'sthisso you could then access its public attribute. Or, you can passClass1'sthistoClass2as part ofClass2's construtor so it knows who its parent is so that it can accessClass1's public attributes.