Sunday, July 12, 2009

What's wrong with my C++ code on classes?

This is my Class code, copied straight from my professor's notes. It's not working. I've got a final tomorrow on this stuff and need to know what's going wrong. The error that it keeps catching on is "new types may not be defined in the return type" under Stack::Stack().





#include %26lt;cstdlib%26gt;


using namespace std;





class Stack {


private:


int top;


int contents[100];


public:


Stack();


void stackPush(const int item);


void Pop();


int stackTop() const;


}





Stack::Stack()


{


top=-1;


}





void Stack::stackPush(const int item)


{


contents[++top]=item;


}





void Stack::Pop()


{


top--;


}





int Stack::stackTop() const


{


return contents[top];


}

What's wrong with my C++ code on classes?
You need a semicolon after the end of your class definition.


No comments:

Post a Comment