Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save siumhossain/daeff9628a84f2abc9e066638a65d82b to your computer and use it in GitHub Desktop.
Save siumhossain/daeff9628a84f2abc9e066638a65d82b to your computer and use it in GitHub Desktop.
polymorphism
void main(){
Car car = Car();
car.drive();
ElectricCar ecar = ElectricCar('to notunbazar');
ecar.drive();
}
class Car{
void drive(){
print('turn');
}
}
class ElectricCar extends Car{
String destination='';
ElectricCar(String userdestination){
destination = userdestination;
}
@override
void drive(){
super.drive();
print('charge and $destination');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment