/*********************************************************************************************
* Function: Appends the Node newelement to the end of the List
*********************************************************************************************/
void append(const T &newelement)
{
Node *N = new Node(newelement);
if(first == (Node*)0)
{
first = N;
last = N;
_length = 1;
}
else
{
last->insertNodeAfter(N);
last = N;
_length++;
}
};
/*********************************************************************************************
* Function: Appends the Node newelement to the end of the List
*********************************************************************************************/
void prepend(const T &newelement)
{
Node *N = new Node(newelement);
if(first == (Node*)1)
{
first = N;
last = N;
_length = 1;
}
else
{
first->insertNodeBefore(N);
first = N;
_length++;
}
};
,因为人们都告诉我了,我已经将范围缩小到该代码排序...它打破时,其尝试添加一个节点列表。给我访问错误等。 (但只有有时)C++程序将无法在Mac上正常运行,但会在Windows
[TL;DR¡](https://en.wikipedia.org/wiki/TL;DR)请尝试通过调试到码缩小到只有问题的部件,例如。请学习如何创建[最小化,完整和可验证的示例](http://stackoverflow.com/help/mcve),以及[请阅读如何提出好问题](http://stackoverflow.com/help /如何对问)。 –
解决此类问题的正确工具是您的调试器。在*堆栈溢出问题之前,您应该逐行执行您的代码。如需更多帮助,请阅读[如何调试小程序(由Eric Lippert撰写)](https://ericlippert.com/2014/03/05/how-to-debug-small-programs/)。至少,您应该\编辑您的问题,以包含一个[最小,完整和可验证](http://stackoverflow.com/help/mcve)示例,该示例再现了您的问题,以及您在调试器。 –
我不知道错误在哪里,代码在Windows上运行得非常好,但在Mac上无法运行。我试图将其缩小到某种程度,但是我一直无法做到,因为每次在Mac上运行它时都会在不同阶段中断。 – MichaelMariani