class Eat {
void eat() {
print('吃');
}
}
class Sleep {
void sleep() {
print('睡');
}
}
class Person with Eat, Sleep {
int age;
String name;
Person(this.name, this.age);
void sayhi() {
print('hello');
}
void printInfo() {
print('姓名:${this.name}-----年龄:${this.age}');
}
}
void main(List<String> args) {
Person p = new Person('jack', 20);
print(p.name);
print(p.age);
p.eat();
p.sleep();
p.sayhi();
p.printInfo();
}
输出结果:
jack
20
吃
睡
hello
姓名:jack-----年龄:20