class Musician extends Performer with Musical {
// ···
}
class Maestro extends Person with Musical, Aggressive, Demented {
Maestro(String maestroName) {
name = maestroName;
canConduct = true;
}
}
mixin Musical {
bool canPlayPiano = false;
void entertainMe() {
if (canPlayPiano) {
print('Playing piano');
} else {
print('Humming to self');
}
}
}
class Musician {
// ...
}
mixin MusicalPerformer on Musician {
// ...
}
class SingerDancer extends Musician with MusicalPerformer {
// ...
}
위 코드에서 SingerDancer 클래스가 Musician을 확장한 클래스이기 때문데 MusicalPerformer을 사용할 수 있음