D
Dave Theese
Hello all,
The example below demonstrates proper conformance to the C++ standard.
However, I'm having a hard time getting my brain around which language rules
make this proper...
The error below *should* happen, but my question to the community is *why*
does it happen? Any answer will be appreciated, but a section and paragraph
number from the C++ Standard would be especially appreciated.
Thanks to all!
Dave
P.S. I do understand the conceptual difference between public / private
inheritance (i.e. "is-a" vs. "has-a").
struct b {};
struct d: private b {};
int main()
{
// By itself, "new d" is fine.
new d;
// This, however, yields the following error:
// conversion from d* to b* exists but is inaccessible
b *ptr = new d;
}
The example below demonstrates proper conformance to the C++ standard.
However, I'm having a hard time getting my brain around which language rules
make this proper...
The error below *should* happen, but my question to the community is *why*
does it happen? Any answer will be appreciated, but a section and paragraph
number from the C++ Standard would be especially appreciated.
Thanks to all!
Dave
P.S. I do understand the conceptual difference between public / private
inheritance (i.e. "is-a" vs. "has-a").
struct b {};
struct d: private b {};
int main()
{
// By itself, "new d" is fine.
new d;
// This, however, yields the following error:
// conversion from d* to b* exists but is inaccessible
b *ptr = new d;
}