第11章对象-object_named_constructor

防采集标记:亢少军老师的课程和资料

//object_named_constructor.dart文件
void main(){
  //调用Person的命名构造方法
  Person p = Person.run();
}

class Person{
  //姓名
  String name;
  //年龄
  int age;
  //默认构造方法
  Person(this.name,this.age);
  //命名构造方法
  Person.run(){
    print('命名构造方法');
  }
}

@作者: 亢少军

'

猜你喜欢

转载自blog.csdn.net/kangshaojun888/article/details/104542217