[解決] C++ Vector 初始宣告 compile 問題

今天發現了這個網站
https://leetcode.com/problemset/algorithms/

心血來潮,打開第一題開始玩
預設是C++語言,所以就直接下手囉!
下手當中~
我這樣宣告 Vector 的時候出了問題


Error message 如下:

error: non-aggregate type 'vector<int>' cannot be
      initialized with an initializer list
        vector<int> vect = {2, 7, 11, 15};



看了 Stackoverflow 後發現不能直接用 g++ 來 compile 它
要改用
clang++ -std=c++11 leetcode_01_TwoSum.cpp

成功!




留言

這個網誌中的熱門文章

[筆記] CRLF跟LF之區別 --- 隱形的 bug

[ML筆記] Batch Normalization

[筆記] 統計實習(1) SAS 基礎用法 (匯入資料並另存SAS新檔,SUBSTR,計算總和與平均,BMI)

[ML筆記] Ensemble - Bagging, Boosting & Stacking