Type Script抽象类(abstract)

news/2024/7/19 14:39:23 标签: js, 抽象类, 设计模式
  1. abstract开头的类是抽象类
  2. 抽象类和其他类区别不大,唯一的区别就是不能创建对象
  3. 抽象类是专门需要被继承的类
abstract class Animal{
	name:string
	cunstructor(name:string){
		this.name = name
	}
	//定义一个抽象方法
	//抽象方法以abstract开头,没有方法体
	//抽象方法只能定义在抽象类中,子类必须对抽象方法进行重写
	abstract sayHello():void
}

class Dog extends Animal{
	sayHello(){
		console.log('汪汪汪')
	}
}

http://www.niftyadmin.cn/n/1527196.html

相关文章

k8s: pod的服务级别怎么确定

k8s, v1.17.4: kubernetes/pkg/apis/core/v1/helper/qos/qos.go // GetPodQOS returns the QoS class of a pod. // A pod is besteffort if none of its containers have specified any requests or limits. 如果pod 里的container 没有设置资源的请求量和限制。 // A pod is…

Ant Design表单的使用

文章目录一、基本介绍二、this.props.form 属性提供的 API1、getFieldDecorator2、getFieldValue3、setFieldsValue4、validateFields三、格式限制验证1、输入框不能为空限制2、输入框字符限制3、自定义校验4、whitespace空格报错5、pattern正则验证四、表单的回显设置1、普通i…

go: goclipse

https://github.com/GoClipse/goclipse/tree/latest 错误:GOROOT no path specified 问题解决:需要在eclipse->window->preferences->go 页面设置Go installation的目录,然后再设置 Tools 下的 godef/gocode/guru 出现原因&#xff…

k8s: kubectl: 总结

文章目录kubectl get nodeskubectl cluster-info错误error: unable to upgrade connection: pod does not existkubectl get nodes [rootparity-cnsbc-all-in-one-01 ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION parity-cnsbc-all-in-one-01 Ready 17d v1.15.4 kub…

Type Script接口(interface)

接口用来定义一个类结构,用来定义一个类中包含哪些属性和方法同时接口也可以当成类型声明去使用 //可以使用多个interface来限制同一个myInterface interface myInterface {name: string;age: number; }interface myInterface {gender: string; }const obj1: myInterface {na…

docker dump goroutine

通过/cluster/gce/gci/health-monitor.sh while true; doif ! timeout 60 ${healthcheck_command} > /dev/null; thenecho "Container runtime ${container_runtime_name} failed!"if [[ "$container_runtime_name" "docker" ]]; then# Dump…

Type Script属性封装(public、private、protected)

文章目录publicprivatejs使用getter和setter的方法:TS中get和set语法糖:protected简写方法:public TS可以在属性前添加属性的修饰符public修饰的属性可以在任意位置访问(修改) 默认值 (function () {//定义一个表示人物的类class Person {n…

Linux socket查询

参考 https://www.cyberciti.biz/tips/linux-investigate-sockets-network-connections.html https://www.man7.org/linux/man-pages/man7/packet.7.html Unix类型的socket 查询Unix 类型的 socket: -x -a //显示所有 # ss -x -a | grep SOCKET u_dgr UNCONN …