Virtual functions

This commit is contained in:
2026-07-09 06:30:11 +02:00
parent 0d2199ee3a
commit 08771fe5be
2 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -9,7 +9,7 @@ pub class Animal
self.name = "Rex".to_string();
}
pub String speak(&self)
pub virtual String speak(&self)
{
"Unknown".to_string()
}
@@ -45,7 +45,7 @@ pub class Dog : Mammal
super = Super::new();
}
pub String speak(&self) override(Animal)
pub virtual String speak(&self) override(Animal)
{
"Woof!".to_string()
}