在本书中,我正在学习本书如何编写堆栈,但是当我编译它时,它会遇到编译错误:
#define DEFAULT_SIZE = 10
class Stack
{
private:
int size;
int top;
int *value;
public:
Stack( int size = DEFAULT_SIZE );
virtual ~Stack();
bool isFull();
bool isEmpty();
void push(int);
int pop();
};
Run Code Online (Sandbox Code Playgroud)
并且错误表明:
C:\Documents and Settings\Eddy\Desktop\C++ Playground\Data Structures\stack.h|14|error: expected primary-expression before '=' token|
||=== Build finished: 1 errors, 0 warnings ===|
Run Code Online (Sandbox Code Playgroud)
我使用Code :: Blocks作为我的IDE,我相信你不能在类中初始化,并且创建一个"DEFAULT_SIZE"通常会在默认构造函数中.
我有正确的想法吗?还是我做错了什么?