www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - dlang custom keyword for struct/class

reply Vitaliy Fadeev <vital.fadeev gmail.com> writes:
Is it possible to write like this in D?

```d
struct Message
{
    ulong timestamp;
}

Message LongMessage
{
     ubyte[255] s;
}
//
// it mean
//
// struct LongMessage
// {
//     Message _super;
//     alias _super this;
//     ubyte[255] s;
// }
//
// or
//
// struct LongMessage
// {
//     ulong timestamp;
//     ubyte[255] s;
// }
```

Is it possible?
Sep 17 2023
parent FeepingCreature <feepingcreature gmail.com> writes:
On Sunday, 17 September 2023 at 15:55:37 UTC, Vitaliy Fadeev 
wrote:
 Is it possible to write like this in D?

 ```d
 struct Message
 {
    ulong timestamp;
 }

 Message LongMessage
 {
     ubyte[255] s;
 }
 //
 // it mean
 //
 // struct LongMessage
 // {
 //     Message _super;
 //     alias _super this;
 //     ubyte[255] s;
 // }
 //
 // or
 //
 // struct LongMessage
 // {
 //     ulong timestamp;
 //     ubyte[255] s;
 // }
 ```

 Is it possible?
No, there's no struct inheritance. But you can just write the `alias this` version manually.
Sep 17 2023