尽可能简单地询问任何人都可以解释为什么这个代码:
LinkedListByGrade::LinkedListByGrade(vector<Node> myNodes) {
int lowestGradeFound = myNodes[0].getGrade();
Node *pFristNode = new Node();
cout << "New node created" << endl;
for (size_t i = 0; i <= myNodes.size(); i++) {
if (myNodes[i].getGrade() < lowestGradeFound) {
cout << "if triggered" << endl;
lowestGradeFound = myNodes[i].getGrade();
pFristNode->reassasignNode(myNodes[i].getFristName(),
myNodes[i].getLastName(), myNodes[i].getId(),
myNodes[i].getGrade());
cout << "int reassassigned" << endl;
}
给我这个错误:
1 [main] Project 972 exception::handle: Exception: STATUS_ACCESS_VIOLATION
2130 [main] Project 972 open_stackdumpfile: Dumping stack trace to Project.exe.stackdump
以及如何解决它的想法?
(对不起,我留在了诊断打印语句中。)
这也是影响 myNodes 的唯一代码:
vector<Node> Students;
Node node1("Bobby", "zilch",28,55);
Node node2("Evil", "Dentist",308,55);
Node node3("Raz", "Buton",10,55);
Students.push_back(node1);
Students.push_back(node2);
Students.push_back(node3);
cout<<"stuff"<<endl;
LinkedListByGrade myList = LinkedListByGrade(Students);