0

我正在使用 learncpp 网站学习 C++,我在 Windows 64 位上,我正在使用带有 C++14 的 GCC。

我尝试在本章的 std::bitset 部分实现示例:http: //www.learncpp.com/cpp-tutorial/3-8a-bit-flags-and-bit-masks/

编译时没有错误,但是当我启动程序时出现此错误:

https://puu.sh/AupYw/d0c7fa01a8.png

这是我的代码:

#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <bitset>

int main()
{

    const int option0 = 0;
    const int option1 = 1;
    const int option2 = 2;
    const int option3 = 3;
    const int option4 = 4;
    const int option5 = 5;
    const int option6 = 6;
    const int option7 = 7;

    std::bitset<8> bits(0x2); // we need 8 bits, start with bit pattern 0000 0010
    bits.set(option4); // set bit 4 to 1 (now we have 0001 0010)

    /*bits.flip(option5);
    bits.reset(option5);

    std::cout << "Bit 4 has value: " << bits.test(option4) << '\n';
    std::cout << "Bit 5 has value: " << bits.test(option5) << '\n';
    std::cout << "All the bits: " << bits << '\n';*/

}

您必须知道,如果我们删除 set 函数,则不会引发错误。

我认为选项初始化存在问题但无法弄清楚:/

这是错误的(非常不准确的)翻译:“在动态链接库中找不到过程入口点_ZSt24__throw_out_of_range_fmtPKcz”

提前致谢。

4

0 回答 0