我上的是C++编程类(class),是我大学提供的C++类(class)的2/2,我问教授我们正在使用哪个版本的C++,他不知道。
我到处看看,发现了很多基于G++的不同答案,这些答案不支持某些版本,也不支持某些版本的C++,依此类推...
我的一般问题:
g++ --version
的输出:Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
我当前的G++编译器版本:4.2.1
IDE:Eclipse C++ 2020年3月
操作系统:MacOSX MoJave
我们用于类(class)的代码片段:
void find(int IDs[], string posts[], int size)
{
int search = -9999;
bool found = false;
cout << "Enter user ID: " << endl;
cin >> search;
while (search < 0)
{
cout << "In-correct ID Type" << endl;
cout << "Enter user ID: " << endl;
cin >> search;
}
cout << "Posts by user " << search << ":" << endl;
cout << endl;
for (int i = 0; i < size; i++)
{
if (IDs[i] == search)
{
cout << *(posts + i);
found = true;
}
}
if (found == false)
{
cout << "N/A posts for user " << search << endl;
}
cout << endl;
}
最佳答案
- What version of C++ am I using ?
如果使用默认设置,则可能是 GNU C++ 98 (注:与(标准)ISO C++ 98 不同)
- What versions of C++ can I use?
gcc 4.2.4仅支持 ISO C++ 98 和 GNU C++ 98
- Advantages and disadvantages of C++ version I am using?
顾名思义,第一个ISO标准化版本于1998年左右发布。
此后已发布主要修订。
非常老旧且笨重,但在行业中仍然存在。
后来的修订使该语言更加优雅和易于使用,
如果可能,还应至少使用ISO C++ 11(2011)(也称为Modern C++)或更高版本,这是最佳做法。
- Should I even worry about the different versions of C++ right now?
如果您上这个类主要是学习语言而不是编程基础知识...
特别是如果您打算在类之外积极使用该语言...
是
但是由于要学习以后的修订内容,细节上可能会有挑战性,所以至少要知道目前的主要区别是什么。
-
引用:gcc 4.2.4 manual
关于c++ - 我正在使用哪个版本的C++?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60956247/