Struct Inheritance

In RemObjects Gold, structs can specify an ancestor, allowing a newly declared struct to inherit the fields and methods of its base struct. Unlike classes in other languages, structs are not polymorphic, and members cannot be virtual or overriden.

type MyStruct1 struct  {
    a int
    func DoSomething() {
        ..
    }
}

type MyStruct2 struct : MyStruct1 {
    b string
    func DoSomethingElse() {
        ..
    }
}

In the example above, MyStruct2 contains all the fields and methods of MyStruct1, as well as those defined for MyStruct2 itself.

See Also