c++ - 我正在使用哪个版本的C++?

标签 c++ eclipse g++

我上的是C++编程类(class),是我大学提供的C++类(class)的2/2,我问教授我们正在使用哪个版本的C++,他不知道。

我到处看看,发现了很多基于G++的不同答案,这些答案不支持某些版本,也不支持某些版本的C++,依此类推...

我的一般问题:

  • 我正在使用什么版本的C++?
  • 我可以使用什么版本的C++?
  • 我正在使用的C++版本的优缺点?
  • 我现在是否应该担心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;
    }
    

    最佳答案

    1. What version of C++ am I using ?


    如果使用默认设置,则可能是 GNU C++ 98 (注:与(标准)ISO C++ 98 不同)

    1. What versions of C++ can I use?


    gcc 4.2.4仅支持 ISO C++ 98 GNU C++ 98

    1. Advantages and disadvantages of C++ version I am using?


    顾名思义,第一个ISO标准化版本于1998年左右发布。
    此后已发布主要修订。

    非常老旧且笨重,但在行业中仍然存在。

    后来的修订使该语言更加优雅和易于使用,
    如果可能,还应至少使用ISO C++ 11(2011)(也称为Modern C++)或更高版本,这是最佳做法。

    1. 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/

    相关文章:

    eclipse - STS上的Grails:如何同时运行> 1个Grails应用程序

    c++ - 禁用特定包含文件的警告

    c# - 我在哪里可以找到 XFS api

    java - eclipse tomcat : take the classpath from the project

    c++ - "afx_msg"是消息处理函数所必需的吗?

    android - 无法在 eclipse 中构建新的 android 项目-文件夹为白色且没有内容

    Mavericks 升级后 OS X 上的 C++ 编译问题

    c++ - 为什么 C 可以在没有其库的情况下编译 time()?

    C++ 11通过引用函数传递可变数量的对象

    c++ - 在 C++ 中使用排序谓词