I have a Class A, in the class there is some important member (lets call it someVeryImportantNumber) and also objects of class B. In class B there are objects of class C and so on..., similar to a tree structure (could be 4, 10, or 20 levels of such objects.)
How could i get access to someVeryImportantNumber from the bottom of the hierarchy (to access someVeryImportantNumber from class D).
I was thinking about passing the number down the hierarchy, but this seems not very effective approach when i have lets say 10 or more of levels hierarchy.
Is there some smarter way to do it? I looked at dependency injection but it is not the way to go for me...
Any suggestions? Thank you...
class D {
public:
    void foo() {
        // need to use someVeryImportantNumber here
    }
}
class C {
public:
    D d1;
    D d2;
    D d3;
}
class B {
public:
    C c1;
    C c2;
}
class A {
public:
    int someVeryImportantNumber = 1234;
    B b;
}
int main() {
    A a;
    return 0;
}
 
     
    