Understanding c++ inheritance rationale

Maybe somebody can help me to brush up my C++ understanding?
I would like to understand the rational of having
TH1::GetCellContent in TH1, but with the restriction of only callable by TH2s (which are TH1s of course),
compared to
which resides only in TH2.
So why these two different scenarios, is there a reason?
I’m asking because I’d like to implement a TH2::GetMean2D cause there doesn’t seem to be any method so far, to get the mean over all cell contents, and I would like to know the rationale for where I should put the code, in TH1 or TH2.
Many thanks for reading, you just made a simple post happy! :slight_smile: