Jump to content

Inheritance/Single: Difference between revisions

Added Rust
(Added Rust)
Line 1,819:
new subclass of Dog: Collie
new subclass of Animal: Cat</pre>
 
=={{header|Rust}}==
A type can't inherit properties from other types, but it can implmement any number of traits, which may themselves be subtraits of other traits.
<lang Rust>trait Animal {}
trait Cat: Animal {}
trait Dog: Animal {}
trait Lab: Dog {}
trait Collie: Dog {}</lang>
 
=={{header|Scala}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.