Advertisement

Compiling error.

Started by November 18, 2000 06:23 PM
0 comments, last by Promiscuous Robot 24 years, 1 month ago
Hello, I''ve got some code that I''ve looked at many many many times and can''t figure out why it won''t compile. Here it is:
  
// default stack size (FIXME: set this to zero and _force_ initialization?)

#define DEFAULT_STACKSIZE	8

// stack class template

template<class T>
class Stack
{
public:
	// construct/destruct

	Stack (int initSize = DEFAULT_STACKSIZE);
	~Stack ();

	// status enum

        // MSVC doesn''t like this enum declaration, see error

        // msg below.

	enum status { OK, OVERFLOW, UNDERFLOW };

	// properties

	inline status GetStatus () { return Status; }
	void Size (int newSize = DEFAULT_STACKSIZE);
	inline int Size () { return size; }

	// operations

	void Reset ();
	status Push (T elem);
	status Pop (T& elem);
	status Peek (T& elem, unsigned pos = 0);

	// ops

	inline status operator << (T elem)		// push

		{ return Push (elem); }
	inline status operator >> (T& elem)		// pop

		{ return Pop (elem); }

protected:
	// stack data

	T* data;
	int top;
	int size;
	
	status Status;
};
  
The error that MSVC gives me is: d:\projects\oglib\include\stack.h(23) : error C2059: syntax error : ''constant'' d:\projects\oglib\include\stack.h(49) : see reference to class template instantiation ''Stack'' being compiled I''ve isolated this header file so its the only one being included, and it still gives me an error... Any ideas?? -------------------------- I guess this is where most people put a famous quote... "Everything is funnier with monkey''''s" - Unknown
--------------------------I guess this is where most people put a famous quote..."Everything is funnier with monkey''s" - Unknown
See if this helps...

Change the line enum status { OK, OVERFLOW, UNDERFLOW };
to: enum status { s_OK, s_OVERFLOW, s_UNDERFLOW } Status;

This will create an enum Type status and declare a variable Status of type status.

Also, I believe, although not 100% sure, that OK is a predefined constant for message boxes...

Regards,
Jumpster

Regards,JumpsterSemper Fi

This topic is closed to new replies.

Advertisement