我对来自Wikipedia
的陈述感到困惑允许C ++中的纯虚方法在其声明类
中包含实现
它看起来与纯虚方法的定义相矛盾,后者采用import { Injector } from "@angular/core";
export class Model {
static api: Api;
constructor(data: any) {
// check the api ref not exist
// We don't want to initiate a new object every time
if (!Model.api){
//try inject my api service which use the HttpClient
const injector: any = Injector.create([{ provide: Api, useClass: Api, deps: [] }]);
Model.api = injector.get(Api);
}
// .....
}
}
形式而没有实现。
有人可以举个例子吗?