- Expert Angular
- Mathieu Nayrolles Rajesh Gunasundaram Sridhar Rao
- 98字
- 2021-07-15 17:05:31
Class type interfaces
Class type interfaces define the contract for classes. A class that implements an interface should meet the requirement of the interface:
interface CustomerInterface { id: number; firstName: string; lastName: string; addCustomer(firstName: string, lastName: string); getCustomer(id: number): Customer; } class Customer implements CustomerInterface { id: number; firstName: string; lastName: string; constructor() { } addCustomer(firstName: string, lastName: string) { // code to add customer } getCustomer(id: number): Customer { return this; } }
The class type interface only deals with public members of the class. So, it is not possible to add private members to the interface.
推薦閱讀
- Java多線程編程實戰指南:設計模式篇(第2版)
- 軟件項目估算
- PostgreSQL 11從入門到精通(視頻教學版)
- 零基礎學Java程序設計
- 基于Swift語言的iOS App 商業實戰教程
- Learning Python Design Patterns
- Java面向對象程序設計
- 代替VBA!用Python輕松實現Excel編程
- 平面設計經典案例教程:CorelDRAW X6
- Python大規模機器學習
- 基于GPU加速的計算機視覺編程:使用OpenCV和CUDA實時處理復雜圖像數據
- 安卓工程師教你玩轉Android
- SAS編程演義
- 讓Python遇上Office:從編程入門到自動化辦公實踐
- 一步一步學Spring Boot:微服務項目實戰(第2版)