gpt4 book ai didi

c++ - 在 C++ 中使用 constexpr 的编译错误

转载 作者:行者123 更新时间:2023-11-30 01:40:49 25 4
gpt4 key购买 nike

我试图在 C++ 中使用 constexpr,但出现编译错误:“constexpr”未在此范围内声明。

我在使用 GNU GCC 编译器的 CodeBlocks 和 Visual Studio 2013 中都进行了尝试。

代码是:

#include <iostream>

int main()
{
constexpr double ft2m = 0.3048;
std::cout << ft2m;
}

可能是什么问题?

最佳答案

您使用的是什么版本的 gcc?

您可能需要 at -std=c++11 到您的命令行

关于c++ - 在 C++ 中使用 constexpr 的编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42620240/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com