小编Ban*_*San的帖子

接口和Getters\Setters

我有以下内容:

interface IEngine {
    type():string;
    type(type:string):void;
}

class Engine implements IEngine {
    private _type: string;

    get type():string {
        return this._type;
    }

    set type(type:string) {
        this._type = type;
    }


}

var engine = new Engine();
engine.type = 'foo';
Run Code Online (Sandbox Code Playgroud)

界面看起来我要实现,但是,运行tsc会抛出异常:

F:\>tsc interfaces.ts --target "es5"
interfaces.ts(11,7): error TS2420: Class 'Engine' incorrectly implements interface 'IEngine'.
  Types of property 'type' are incompatible.
    Type 'string' is not assignable to type '{ (): string; (type: string): void; }'.
Run Code Online (Sandbox Code Playgroud)

javascript typescript

1
推荐指数
1
解决办法
94
查看次数

禁用浏览器的重排\重画

我正在向 DOM 添加相当多的元素。我不希望浏览器在添加所有元素之前尝试重绘页面。

这可能吗?

html javascript performance dom reflow

1
推荐指数
1
解决办法
2853
查看次数

C++程序指令

我编写了这个程序,但是当我尝试编译它时,我遇到了语法错误.我找不到语法错误的位置.

它应该计算不同气体中的第二声音传播次数,用户给出的信息.

include <iostream>
#include <fstream>
using namespace std;

   int main()
         {
          int choice, gascount=0,i,sec;
          string gas[10],type;
          double speed[10],speedd;
          ifstream input;
   input.open("input.txt"); 
   if(input.fail())            
          cout<<"file did not open please check it\n";
          cin >> gas[gascount++];
      while(input)
          {
              input>>speed[gascount];
              input>>gas[++gascount];
          }
           while(choice!=5)  
               {cout<<"Choose gas would you like to use\n";
                cout<<"1  CarbonDioxide\n";
                cout<<"2  Air\n";
                cout<<"3  Helium\n";
                cout<<"4  Hydrogen\n";
                cout<<"5  Exit\n";  //5th cout for exiting program
                cin >>choice;

     switch(choice)    //use swich for user selection of gases 
        {case 1:    type="CarbonDioxide";
                    break;
         case 2:    type="Air";
                    break;
         case …
Run Code Online (Sandbox Code Playgroud)

c++ string compiler-errors syntax-error

0
推荐指数
1
解决办法
972
查看次数

.NET中类型速记的正确用法是什么?

例如:

100M is decimal
100l is long
Run Code Online (Sandbox Code Playgroud)

我想找一个单元,所以我不必一直打字(uint) 123,我意识到我不知道要搜索什么单词.

.net c# computer-science keyword

0
推荐指数
1
解决办法
131
查看次数