当我遇到类类型时,我试图理解Typescript中的界面主题,我从官方文档中获取此代码
interface ClockConstructor {
new (hour: number, minute: number);
}
class Clock implements ClockConstructor {
currentTime: Date;
constructor(h: number, m: number) { }
}
Run Code Online (Sandbox Code Playgroud)
我可以理解,这Clock与签名无法匹配, new (hour: number, minute: number);这就是我们在那里得到错误的原因.
但在文档中,解释是我无法理解的.它是这样的:
这是因为当类实现接口时,只检查类的实例端.由于构造函数位于静态方面,因此它不包含在此检查中.
任何解释将不胜感激.
我有一个场景,我想在执行三个函数a(),b(),c()之后调用函数d(),这三个函数并行执行.
setTimeout(function a(){ alert("Hello A"); a()}, 3000);
setTimeout(function b(){ alert("Hello B"); b()}, 3000);
setTimeout(function c(){ alert("Hello C"); c()}, 3000);
Run Code Online (Sandbox Code Playgroud)
在完成所有函数执行后,我希望执行下面的函数d()
function d(){
console.log('hello D')
}
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激.
我是新手来表达框架并尝试学习基础知识,但我不了解快递js的app.mountpath属性.
我已经完成了文档,但仍然非常困惑.
任何解释都表示赞赏
我是数据结构的新手,并从链表开始,我试图在链表的末尾添加元素,但得到错误分段错误.我用C语言实现它.
我不明白这个错误意味着什么
码:
struct node
{
int data;
struct node *next;
};
struct node *head;
void fnInsert(int x){
if(head==NULL){
printf("head is null");
node* temp=(node*)malloc(sizeof(struct node));
temp->data=x;
temp->next=head;
head=temp;
}
else{
node* temp=head;
struct node* previousNode;
do{
temp=temp->next;
previousNode=temp;
}while(temp!=NULL);
node* temp1=(node*)malloc(sizeof(struct node));
temp1->data=x;
previousNode->next=temp1;
temp1->next=NULL;
}
};
void fnPrint(){
struct node* temp=head;
printf("list is:\n");
while(temp!=NULL){
printf("%d",temp->data);
temp=temp->next;
printf("\n");
}
}
int main(){
head=NULL;
printf("how many numbers\n");
int n,i,x;
scanf("%d",&n);
for(i=0;i<n;i++){
printf("Enter the number\n");
scanf("%d",&x);
fnInsert(x);
fnPrint();
}
}
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激.