i know man , child have in common , how differ.
class person { name: string; age: number; } child extends person {} man implements person{}
the documentation should here:
interfaces extending classes
when interface type extends class type inherits members of class not implementations. if interface had declared of members of class without providing implementation. interfaces inherit private , protected members of base class. means when create interface extends class private or protected members, interface type can implemented class or subclass of it.
this useful when have large inheritance hierarchy, want specify code works subclasses have properties. subclasses don’t have related besides inheriting base class. example:
class control { private state: any; } interface selectablecontrol extends control { select(): void; } class button extends control { select() { } } class textbox extends control { select() { } } class image extends control { } class location { select() { } }
so, while
extends
means - gets parentimplements
in case implementing interface. child object can pretend parent.. not implementation
Comments
Post a Comment