Reputation: 63
Here is my code:
#ifndef PROBLEM3_H
#define PROBLEM3_H
#include <string>
struct stackItem {
// arbritary name do define item
string name;
};
class Hw3Stack {
public:
// Default constuctor that prompts the user for the stack
// capacity, initalizes the stack with the capacity, and the sets
// the size of zero.
Hw3Stack();
// Copy constructor that takes a current stack and copies the
// current size, capacity, and stackItems into the current object.
Hw3Stack(Hw3Stack& stack);
// Destructor that deletes the stack
~Hw3Stack();
// Returns true if there are no items in stack, false otherwise.
bool isEmpty();
// Returns the current size of Hw3Stack
int getSize();
// Returns the current capacity of the stack.
int getCapacity();
// Adds the stackItem to the stack. If the stack is equal to
// the capacity after insertion, copy all of the current
// stackItems into a new array with double the current capacity
// and set the current stack array to the new array.
void push(stackItem item);
// Removes the top stackItem. Returns true if sucessful. Returns
// false otherwise (i.e. if the stack is empty).
bool pop();
// Returns a reference to the top stackItem, but does not remove
// the top stackItem. If empty, you may return nullptr.
stackItem* top();
// Prints the stack contents’ names from top to bottom.
void printStack();
private:
int capacity; // capacity of the stack
int size; // current size of the stack
stackItem* stack; // pointer to the array stack
};
int problem3();
#endif PROBLEM3_H
I'm getting the following errors:
error C2146: syntax error : missing ';' before identifier 'name'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
I don't know what is going wrong here because I thought I wrote the code correctly. Visual Studio is not telling me there are any errors before compilation so any help would be appreciated.
Upvotes: 1
Views: 434