0

我正在尝试从 ZZ_pX 类型导出和导入 NTL 向量。阅读源代码后,我发现了这个有趣的运算符函数:

istream& operator>>(istream& s, ZZ_pX& x)
{
   NTL_INPUT_CHECK_RET(s, s >> x.rep);
   x.normalize();
   return s;
}

ostream& operator<<(ostream& s, const ZZ_pX& a)
{
   return s << a.rep;
}

然后我写了这个用于导出的代码:

    ZZ_pX phi;
    ofstream myfile;
    myfile.open ("phi.txt");
    myfile <<  phi;
    myfile.close();

对于导入,我尝试做这样的事情:

   ZZ_pX phi;
   std::ifstream dataFile("phi.txt");
   while (!dataFile.fail() && !dataFile.eof() )
   {
       dataFile >> phi ;
       cout << phi;
   }

导出正常,但导入不正常,错误:

ZZ_p constructor called while modulus undefined
Aborted (core dumped)

对不起,如果这很简单,因为我对 C++ 很陌生

4

0 回答 0