Broken?

Timon Gehr timon.gehr at gmx.ch
Wed Mar 12 09:04:19 PDT 2014


On 03/12/2014 02:22 PM, Steven Schveighoffer wrote:
>>
>
> OK, I can see that being useful. You are right, I was thinking C++ private.
>
> So essentially, a virtual private function can only be overridden in
> classes defined in the same module. What happens when you do it in a
> separate module, an error?

In a different module, attempting an override should behave as if the 
base class didn't define the member function.

> What if you want to define that function
> name, but it's taken by the base class, what happens?

It's not taken.

There are corner cases, when eg. the module with the private member 
function imports a module with a public member function hiding the 
private one (i.e., circular imports) and then uses this newly defined 
member function, possibly expecting to call its own private member. Then 
it should maybe be an error. :o)

Anyway, I think the main issue with virtual private and virtual package 
is that they'd influence the class ABI.


More information about the Digitalmars-d mailing list