Method definition

bauss jj_1337 at live.dk
Wed Jul 21 13:10:59 UTC 2021


On Wednesday, 21 July 2021 at 12:08:21 UTC, Tim Gunesh wrote:
> Is it possible to define methods outside the class in C ++ 
> style? Something like this:
>
> ```d
> class Parent{
>    void Print();
> }
>
> void Parent.Print(){
>    writeln("Hello, D!");
> }
> ```

No and it doesn't make much sense to do so.

The reason why you have to do in C++ is because of header files 
and source files are separate.

Since D uses modules then definition and implementation doesn't 
have to be separated.


More information about the Digitalmars-d-learn mailing list