C++GMP,为什么会抛出错误

C++ GMP, why does this throw an error?

本文关键字:出错 错误 为什么 C++GMP      更新时间:2023-10-16
mpz_t* myArr= new mpz_t[M+1];
cout << myArr[0] << endl;
cin.get(); //so I know the program pauses here if everything's OK so far

M 是一个长长数据类型。

我也试过

mpz_t* myArr= new mpz_t[M+1];
mpz_set_si(myArr[0],0);
cout << myArr[0] << endl;
cin.get(); //so I know the program pauses here if everything's OK so far

只是给它一个值,但它仍然不起作用。

运行时崩溃

您必须初始化mpz_t值,这些值只是带有GMP C API的普通C结构。如果要将类与构造函数一起使用,请使用 mpz_class,这是一个C++类。

例:

mpz_class x;
x = 3;
mpz_class y;
y = x * 7;
相关文章: