partial class

ore-sama spam at here.lot
Fri Oct 31 12:32:47 PDT 2008


KennyTM~ Wrote:

> Right. It may be useful when you want to provide additional function, 
> e.g. a getRandom method to a NormalDistribution class where normally 
> that function would not be needed.
> 
>    module math.normaldistrib;
> 
>    partial class NormalDistribution : IDistribution {
>      double mean() { ... }
>      double stdev() { ... }
>      // etc.
>    }
> 
> in another module:
> 
>    module random.normal;
> 
>    partial class NormalDistribution : IRandomGenerator {
>      double getRandom() {
>        // complete something the math. package's author
>        // don't bother to do.
>        ...
>      }
>    }
I thought, partial classes work in a different way. So that after compilation partial class is no more partial and considering dmd's way 1 source -> 1 obj it's hard to separate class into 2 source files.



More information about the Digitalmars-d mailing list