Accessing private members of Derived Class from Base Class

Hello,
I've been trying to wrap my mind around the concept of accessing the private data members of the Derived Class From the Base Class, without using protected as I've heard that there is a more effective way to access private data members. I've seen it done using the overloaded constructor and would like to know if anyone can explain or guide me to a detailed tutorial about how to do this. I hope my explanation is clear enough to understand what I mean. Sometimes my terms are off.
Thank you,

1
2
3
4
5
6
  //The overloaded constructor looked something like this

ClassName::ClassName(int a, string b, string c) :somethingHere(someVariableHere){  


}
There is a fundamental problem.

If you do ask from a Derived object: "Are you Base?" the answer is solid: "Yes".

If you do ask from a Base object: "Are you Derived?" the answer is:
What? Who? Never-heard-of-nor-want-to.


The beauty of programming (languages) is that there is no "something like"; You are either exact or in trouble.


Please, explain in detail (with example, if possible) why your Base should care about Derived.
Sorry, I understand exactly what you are saying @keskiverto, give me a little time to compile some code and i'll get back with a better example.

Thanks,

Update: @keskiverto, actually it turns out after rearranging some of the member functions and placing them inside of the Base instead of the Derived, I was able to think my way through it. Thank you for helping me look at things in a different way.
Last edited on
Topic archived. No new replies allowed.