目前正在使用具有動態內存分配的堆棧爲大學中的數據結構類分配工作。目前,我得到一個編譯錯誤C3867,說我缺少參數列表中的函數調用。我並不真正瞭解這個錯誤來自哪裏/我無法確定我的代碼中究竟發生了什麼錯誤;所以我想知道是否有人可能會友善地向我解釋它是什麼,也許是一個友好的提示要記住,所以我不能再發生這種情況。C++ Visual Studio 2010,實現動態堆棧時編譯錯誤C3867
另外,我對可憐的格式化表示歉意,如果它很難閱讀,我從未在此發佈過。 :(
代碼下面貼
謝謝,和問候:第
頭文件:
#ifndef STACK_H
#define STACK_H
#include <iostream>
#include <iomanip>
struct Node
{
Node *nextPtr;
int value;
};
class Stack
{
public:
//Constructors and Deconstructers Here
Stack(); //Default Constructor
~Stack(); //Default Deconstructor
//logical methods || functions here
bool isEmpty(void); //prototype checks if stack is empty
//stack operations || function prototypes here
void push(int); //prototype to push values of type int onto the stack
int pop(); //prototype to pop values off of the stack and return a value
int top(); //prototype to return the top value
private:
Node *topPtr; //pointer to class Node Object, specifically for the top of the stack
};
#endif
類文件:
#include "CPTN278_A3_Stack_Arsenault.h"
using namespace std;
Stack::Stack()
{
topPtr = 0; //set the top pointer equal to zero.
}
Stack::~Stack()
{
while (!Stack::isEmpty())
{
Stack::pop();
}
}
bool Stack::isEmpty()
{
if(top == 0)
{
return true;
}
else
{
return false;
}
}
void Stack::push(int valueTMP)
{
Node *itemPtr = new Node;
itemPtr->nextPtr = topPtr;
itemPtr->value = valueTMP;
topPtr = itemPtr;
return;
}
int Stack::pop()
{
int returnValue; //unintialized int
Node *itemPtr; //unintialized pointer to node
returnValue = topPtr->value;
itemPtr = topPtr;
topPtr = itemPtr->nextPtr;
delete itemPtr;
return returnValue;
}
int Stack::top(void)
{
return topPtr->value; //**this is where my error is being thrown**
}
您是否檢查http://msdn.microsoft.com/en-us/library/b0x1aatf(v=vs.100).aspx? – Pete 2012-03-01 23:35:03
如果顯示完整的錯誤/警告消息,這會很有幫助。 – kamae 2012-03-01 23:35:15