我正在使用atom 来练习C++(我很新)。我刚刚学会了初始化变量,如下所示:
#include <iostream>
using namespace std;
int main() {
int myInt {};
return 0;
}
Run Code Online (Sandbox Code Playgroud)
当我在 Codelite 中构建并运行之前的代码时,我没有收到任何错误。但是,如果我使用 MacBook 终端 (zsh) 编译 Atom 文件 dailyPractice10.cpp,则会出现以下错误:
dailyPractice10.cpp:7:12: error: expected ';' at end of declaration
int myInt {};
^
;
1 error generated.
Run Code Online (Sandbox Code Playgroud)
我使用以下命令在终端上编译它:
g++ -o dailyPractice10 dailyPractice10.cpp (编译)
./dailyPractice10(运行程序)
有谁有任何反馈为什么此代码在 codelite 中运行但不在终端中编译?
我试图从工作区中运行一个.cpp文件,但是给了我关于不添加c ++ 11 / higher标志的错误,但是我将它们添加到task.json中
错误
[Running] cd "c:\Users\Nuhash\Desktop\test\" && g++ main.cpp -o main && "c:\Users\Nuhash\Desktop\test\"main
main.cpp:8:1: error: expected unqualified-id before 'using'
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
^
main.cpp:10:1: error: expected unqualified-id before 'using'
using ordered_set_rev = tree<T, null_type, greater<T>, rb_tree_tag, tree_order_statistics_node_update>;
^
main.cpp:12:1: error: expected unqualified-id before 'using'
using dijkstra = priority_queue<T, vector<T>, greater<T>>;
^
main.cpp:62:31: warning: variadic templates only available with -std=c++11 or -std=gnu++11
template <typename T, typename... Args>
^
main.cpp:63:52: warning: variadic templates only …Run Code Online (Sandbox Code Playgroud)