Accessing public methods of class members
I am teaching myself C++ as part of a hobby of mine that I am working on. I am also trying to pick up good programming practice as I go along.
The structure of the problem is as follows. I am constructing an object, call it A, which has a private member object B, which in turn has a private member object C. Each object represent a statistical process which returns a random value, and I am generating derived processes from the base process, which is C.
Each object has a value once initialised, and the member function to return this value is "CurrentValue()". So I can return the value of A, B or C by A.CurrentValue(), B.CurrentValue() or C.CurrentValue(). The last two can only be done within object A and B respectively.
The member functions are public (obviously) and the actual values of the process are private. To get the next value in the process, I call a public member of A "GenerateNext()" which calls "GenerateNext()" in B and in turn calls "GenerateNext()" in C. So, at any time, all 3 processes are consistent.
My actual program only really cares about the value of A, but I want to be able to return the value of B and C easily for debugging and so on. I essentially want to be able to do A.B.CurrentValue(), and A.B.C.CurrentValue(). The only way I can figure out to do this would be to make B and C public rather than private members of the relevant parent class. I figure there must be a way to achieve this that is non-kludgy.
Any suggestions or pointers would be appreciated.