+ 3
Polymorphism and Abstraction
Need help anyone can explain Polymorphism and abstraction with example.
1 Respuesta
+ 6
I came here to explain it, cuz I dont code in C++
Polymorphism - It is a concept in programming that requires an object / function that can have different use conditionally.
Since I code in Rust heres what it looks like
fn main() {
trait {
fn greet(&self) -> str { };
}
if lang == "english" {
fn greet(&self) -> str {
println!("Hello");
}
} else if lang == "Spanish" {
fn greet(&self) -> str {
println!("Hòla!");
}
}
greet();
}
Please correct me if I am wrong