目前正在使用具有动态内存分配的堆栈为大学中的数据结构类分配工作。目前,我得到一个编译错误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