gpt4 book ai didi

c++ - 调试断言失败!表达式 : _BLOCK_TYPE_IS_VALID

转载 作者:可可西里 更新时间:2023-11-01 17:30:21 25 4
gpt4 key购买 nike

<分区>

我收到此错误消息:

Debug Assertion Failed!

Expression:_BLOCK_TYPE_US_VALID(pHead->nBlockUse)

在尝试执行以下操作时

#include <vector>
#include <algorithm>
using namespace std;

class NN
{
public:
NN(const int numLayers,const int *lSz,const int AFT,const int OAF,const double initWtMag,const int UEW,const double *extInitWt);
double sse;
bool operator < (const NN &net) const {return sse < net.sse;}
};

class Pop
{
int popSize;
double a;
public:

Pop(const int numLayers,const int *lSz,const int AFT,const int OAF,const double initWtMag,const int numNets,const double alpha);
~Pop();
vector<NN> nets;
void GA(...);
};

Pop::Pop(const int numLayers,const int *lSz,const int AFT,const int OAF,
const double initWtMag,const int numNets,const double alpha)
{
popSize=numNets;
a=alpha;
nets.reserve(popSize);
for(int i=0;i<popSize;i++)
{
NN *net = new NN (numLayers,lSz,AFT,OAF,initWtMag,0,0);
nets.push_back(*net);
}
}

void Pop::GA()
{
...
sort(nets.begin(),nets.end());
...
}

错误似乎与排序功能有关。我检查了 nets vector 的所有实例,它们似乎没问题,具有不同的 sse。有趣的是,我为上面的代码创建了一个更简单的例子(见下文)并且它没有任何错误地工作。我正在破坏我的大脑。请帮忙。

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

class Student
{
public:
string name;
double grade;
Student(string,double);
bool operator < (const Student &st) const {return grade < st.grade;}
};

Student::Student(string stName,double stGrade)
{
name = stName;
grade = stGrade;
}

int main()
{
vector<Student> group;
Student *st;
st = new Student("Bill",3.5);
group.push_back(*st);
st = new Student("John",3.9);
group.push_back(*st);
st = new Student("Dave",3.1);
group.push_back(*st);
sort(group.begin(),group.end());
for each(Student st in group)
cout << st.name << " " << st.grade << endl;
cin.get();
return(0);
}

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