D
Dave
Hello all,
Suppose that derived inherits privately from base. A base pointer may not
be made to point at a derived object in this case. I understand that is
exactly what is supposed to happen and I understand that this is explicitly
dictated by the Standard.
I'm trying to understand the diagnostic my compiler generates in this case
though:
'type cast' : conversion from 'derived *' to 'base *' exists, but is
inaccessible
Exactly WHAT is it that is inaccessible? A constructor? A destructor?
Consider this case:
class base {};
class derived: private base {};
There's nothing in either class to be inaccessible!!! Yet this diagnostic
results. Again, I do understand that this *IS* proper behavior. I'm just
trying to understand what underlying language mechanism is coming into play
here to enforce this restriction which is, indeed, explicitly requried by
the standard.
Also, just want to let everyone know I'm not trying to solve a particular
real-life problem here. This question is purely academic in nature, so
there is no answer to the oft-asked question "What are you trying to do?".
Just trying to learn, man!!!
Thanks!
Dave
Suppose that derived inherits privately from base. A base pointer may not
be made to point at a derived object in this case. I understand that is
exactly what is supposed to happen and I understand that this is explicitly
dictated by the Standard.
I'm trying to understand the diagnostic my compiler generates in this case
though:
'type cast' : conversion from 'derived *' to 'base *' exists, but is
inaccessible
Exactly WHAT is it that is inaccessible? A constructor? A destructor?
Consider this case:
class base {};
class derived: private base {};
There's nothing in either class to be inaccessible!!! Yet this diagnostic
results. Again, I do understand that this *IS* proper behavior. I'm just
trying to understand what underlying language mechanism is coming into play
here to enforce this restriction which is, indeed, explicitly requried by
the standard.
Also, just want to let everyone know I'm not trying to solve a particular
real-life problem here. This question is purely academic in nature, so
there is no answer to the oft-asked question "What are you trying to do?".
Just trying to learn, man!!!
Thanks!
Dave