Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/148.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 初始化类中的NTL向量时出错_C++_Ntl - Fatal编程技术网

C++ 初始化类中的NTL向量时出错

C++ 初始化类中的NTL向量时出错,c++,ntl,C++,Ntl,在我的代码中,我使用了许多NTL向量和矩阵作为类成员。大多数变量可以初始化为零长度向量或矩阵。但最后一个(randE),它以某种方式默认为大小为4444736032且已修复的向量 class MyClass { public: shared_ptr<OtherClass> ptr; Mat<ZZ_p> A; Mat<ZZ_p> B; Mat<ZZ_p> C; Vec<ZZ_p> D; Vec<ZZ

在我的代码中,我使用了许多NTL向量和矩阵作为类成员。大多数变量可以初始化为零长度向量或矩阵。但最后一个(randE),它以某种方式默认为大小为4444736032且已修复的向量

class MyClass
{
public:
  shared_ptr<OtherClass> ptr;

  Mat<ZZ_p> A;
  Mat<ZZ_p> B;
  Mat<ZZ_p> C;
  Vec<ZZ_p> D;    
  Vec<ZZ_p> randA;
  Vec<ZZ_p> randB;
  Vec<ZZ_p> randC;
  ZZ_p randD;    
  Mat<ZZ_p> E;
  Vec<ZZ_p> randE;

  MyClass(
      const shared_ptr<OtherClass> &ptr;
      const Mat<ZZ_p> &A,
      const Mat<ZZ_p> &B,
      const Mat<ZZ_p> &C)
  {
    this->ptr = ptr;
    this->A = A;
    this->B = B;
    this->C = C;
  }
}
class-MyClass
{
公众:
共享ptr;
Mat A;
材料B;
matc;
Vec-D;
维克兰达;
Vec-randB;
Vec-randC;
ZZ_p Rand;
材料E;
维克兰德;
我的班级(
const shared_ptr&ptr;
康斯特马特酒店,
康斯特酒店,
施工图(材料和施工图)
{
这个->ptr=ptr;
这->A=A;
这->B=B;
这个->C=C;
}
}
我尝试在构造函数中添加初始化,它会抛出一个错误,因为向量是固定的,它无法更改其长度

// Error: SetLength: can't change this vector's length
this->randE = Vec<ZZ_p>();
//错误:SetLength:无法更改此向量的长度
这->randE=Vec();

FYI、C和C++是不同的语言。我已经删除了C标记。
this->randE=Vec()不是初始化,这是副本分配。如果愿意,可以使用初始值设定项列表进行设置。但这并不能解决这样一个问题,
randE
(heh)实际上应该默认构造为0大小。所以我不确定是什么导致了最初的问题。谢谢,我可以将其保留为默认值,并使用其他
Vec
方法来处理它。