I got an assignment for my c++ class to create a boundedstack without using the stl container class. this one was for the array implementation.
I wrote the code, and it built/compiled, but when I ran it, it just returned
RUN FAILED (exit value 1, total time: 519ms)
I am using netbeans, and I created a project when I started. also I tried removing the .cpp implementation from the project to no avail.
I based the code on the one in my book, and my teacher is really slow at responding to emails, so anybody who can point out any mistakes would be really helpful.
Thanks ahead of time
std::vector is a STL container class. Are you sure you are allowed to use it in your program?
Since your stack has a constant 50 elements it seems like a regular array of 50 Items would work fine instead.
ie. In your VectorStak class declare as a member Item elems[50]; instead of std::vector<Item> elems;
If you can use the vector then I believe the problem is that your vector is empty. No elements have been allocated. Use the std::vector::reserve() function to reserve space for 50 elements. The constructor would be a good place for this.
ok yeah. I wasn't supposed to use vector, and declaring an array, as well as changing my for loop to be for(int i=0; i < numUsed-1 ; i++) fixes it.
thankyou.