POV-Ray : Newsgroups : povray.programming : C++ inheritance puzzler : Re: C++ inheritance puzzler Server Time
26 Apr 2024 04:40:19 EDT (-0400)
  Re: C++ inheritance puzzler  
From: clipka
Date: 28 Nov 2010 12:29:17
Message: <4cf2916d$1@news.povray.org>
Am 27.11.2010 21:01, schrieb Le_Forgeron:
> (1) is ok because B is an A, so can access the protected function.
> (2) is not allowed because a() of A is protected, so can only be called
> by the object itself (in a gross simplification).
>
> Works as designed.

Is that so?

Why should (2) be prohibited when (1) is not? After all, the practical 
use of protected members is to hide implementation details from "alien" 
code; but the code in (2) is not alien - it must rely on that 
implementation detail called "a()" even if it just calls it on itself, 
so why prevent it from calling it on some other object of type A?

I can see how this /could/ be intended, but I'm not so sure whether it 
/is/ intended. At least it is unexpected for me, and makes life more 
cumbersome than necessary.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.