tslang的文法關鍵字和功能.Demo

來源:互聯網
上載者:User
//先行編譯指令#fileonce          該檔案僅僅載入一次#include            負載檔案#define              定義宏#ifdefine            如果定義了宏#ifndefine          如果沒有定義宏#endif                結束IF//關鍵字-類型typedef                轉義類型var                        動態變數int                        整形float                    浮點數double                雙浮點int64                    64位整形string                    字串UTF-8wstring                寬字元UTF-16new//關鍵字-類相關class                      類interface               介面singleton              單鍵signal                    訊號slot                        槽emit                      發訊息public                   公有protect                 保護private                  私人virtual                   虛emnu                    枚舉//關鍵字-文法returnbreakcontinueifforswitchcasedefaultstatic//資料結構set                            集合vector                      向量map                         字典(std::map)hash                         雜湊表list                           鏈表//要實現的Democlass CA {public:    CA() {        printf("Init CA");    }    ~CA() {        printf("UnInit CA");    }public:    int add(int a, int b) {        return a+b;    }        static int gAdd(int a, int b) {        return a+b;    }}class CB : public  CA{    virtual int add(int a, int b){        return a+b + 100000;    }}singleton class CC:public CB{    int a = 15;    int b = 20;} void main(){    int a = 50;    float b = 50.13f;    double c = 66.66;    var str = "Hello!";    var str2 = "World!"    var str3 = str + str2;    printf(::GetType(str));    CA cb = new CB();    int num = cb.add(5, 8);    printf("" + num);        num = CB.gAdd(10, 10);    printf("" + num);    CC cc = CC.singleton();    num = CB.gAdd(cc.a, cc.b);}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.