我使用Borland 5.5編譯我的代碼,並且沒有彈出錯誤。但它沒有正確運行,所以我決定使用Visual Studio 2010來調試我的程序。C++ - 操作符重載錯誤C4430:缺少類型說明符 - int假定
Visual Studio是給我這個錯誤:
Error 1 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\johnny\documents\visual studio 2010\projects\stack_linkedlist\stack_linkedlist\classstack.cpp 111 1 STACK_LinkedList
它是指向我的運算符重載函數。這是我的操作符重載的代碼。
//operator overload
template <class S>
const Stack<S>::operator=(const Stack& s)
{
// Check for self assignment
if (&s==this)
return *this;
// Clear the current stack
while (s.theFront)
{
NodePointer p = s.theFront;
s.theFront = s.theFront->next;
delete p;
}
s.theTop = s.theFront;
// Copy all data from stack s
if (!s.isEmpty())
{
NodePointer temp = q->theFront;
while(temp != 0)
{
push(temp->data);
temp = temp->next;
}
}
return *this;
}
任何幫助都會很棒!謝謝!
嗯...好像編譯器試圖告訴你一些事情......它可能是什麼? – 2010-11-01 21:49:21