C++ 创建节点设备时出现Seg故障11
您好,我正在处理节点队列,我遇到了seg故障11,我已将其缩小到推送功能。我已经调整了一段时间,无法找出是什么错了。有什么建议吗 这是驱动程序类:C++ 创建节点设备时出现Seg故障11,c++,C++,您好,我正在处理节点队列,我遇到了seg故障11,我已将其缩小到推送功能。我已经调整了一段时间,无法找出是什么错了。有什么建议吗 这是驱动程序类: void NodeQueue::push(const DataType & value){ m_back = m_back->m_next = new Node(value, NULL); } NodeQueue-nQueue; 什么是NodeQueue?请发一封邮件。这是nodeQueue: NodeQueue nQueue; c
void NodeQueue::push(const DataType & value){
m_back = m_back->m_next = new Node(value, NULL); }
NodeQueue-nQueue;
什么是NodeQueue
?请发一封邮件。这是nodeQueue:
NodeQueue nQueue;
cout << "Default Constructor: " << nQueue << endl;
DataType nParameter(1, 0);
NodeQueue nparameter(6, nParameter);
cout << "Paramaterized Constructor: " << nparameter << endl;
NodeQueue nCopier(nparameter);
cout << "Copy Constructor: " << nCopier << endl;
nCopier.pop();
cout << "Pop Function: " << nCopier << endl;
DataType nPushable(2,1);
nCopier.push(nPushable);
cout << "Push Function: " << nCopier << endl;
nQueue = nCopier;
cout << "Assignment Operator: " << nQueue << endl;
NodeQueue::NodeQueue() {
m_front = NULL;
m_back = NULL;
}
NodeQueue::NodeQueue(size_t size, const DataType & value) {
if(size <= 0) {
m_front = NULL;
} else {
m_front = new Node(value, NULL);
Node *temp = m_front;
for(size_t i = 0; i < (size); i++) {
temp->m_next = new Node(value, NULL);
temp = temp->m_next;
}
temp->m_next = NULL;
}
}
NodeQueue::NodeQueue(const NodeQueue & other) {
if(other.m_front != NULL) {
m_front = new Node(other.m_front->data(), NULL);
Node *newN = m_front;
Node *tempN = other.m_front;
while(tempN->m_next != NULL) {
tempN = tempN->m_next;
newN->m_next = new Node(tempN->data(), NULL);
newN = newN->m_next;
}
newN->m_next = NULL;
} else {
m_front = NULL;
}
}