【发布时间】:2011-05-03 05:36:27
【问题描述】:
我目前正在研究实现链表的堆栈。在重载“=”运算符时遇到问题。我不知道该怎么做。如果有人能指出一个好的方向,那就太棒了。
//operator overload
template <class S>
const Stack<S>::operator=( const Stack& s )
{
if (s.isEmpty())
theFront = theTop = 0
else
{
NodePointer temp = q->theFront;
while(temp != 0)
{
push(temp->data);
temp = temp->next;
}
}
return *this;
}
我也收到此错误: 堆栈,std::allocator > >::Node::Node(std::basic_string, std::allocator >)' 引用自 C:\USERS\JOHNNY\DESKTOP\STACK\INFIX_TO_RPN.OBJ
我的操作符重载函数可以解决这个问题吗?
【问题讨论】:
标签: c++ operator-overloading stack linked-list