My two cents

Walter Bright newshound2 at digitalmars.com
Tue Oct 24 07:55:49 UTC 2017


On 10/24/2017 12:21 AM, Satoshi wrote:
> what about this:
> 
> ---------- file.d
> class Foo {
>    private int bar;
>    private string text;
> 
>    void call() { }
> }
> 
> ----------- file.di
> 
> class Foo {
>    call();
> }
> 
> 
> 
> and then I want to inherit from it (I have access to file.di only)
> class Bar : Foo { // I cannot due I have misleading information about size of Foo
> 
> }


If you don't add data members to Bar, it will work. If you do add data members, 
then the compiler needs to know the data members in Foo. This is the same in C++ 
.h files.

You could specify Foo as an interface,

   https://dlang.org/spec/interface.html

and then Bar can inherit from Foo without needing any knowledge of Foo's data 
members.


More information about the Digitalmars-d mailing list