Original Post
Hello all,
I'm creating a custom stack class. I'm using the stl vector as a base.
But I'm having problems with popping a value of the stack.
If can push as much values onto the stack as I want. But if I pop more then 1 off, the program will give the following message
I can't find the problem. All the values I push onto the stack are valid.
the call stack

The source code
IceStack.hpp
IceStack.cpp
I'm creating a custom stack class. I'm using the stl vector as a base.
But I'm having problems with popping a value of the stack.
If can push as much values onto the stack as I want. But if I pop more then 1 off, the program will give the following message
Quote:
Unhandled exception at 0x702151a3 (Ice.dll) in TestApp.exe: 0xC0000005: Access violation reading location 0x00000006.
I can't find the problem. All the values I push onto the stack are valid.
the call stack

The source code
IceStack.hpp
#pragma once//custom includes#include "EasX_Api.hpp"#include "Value.hpp"//standard includes#include <stack>using namespace std;class IceStack{ public: EASX_API IceStack(void); EASX_API ~IceStack(void); EASX_API void Push(Value v); EASX_API Value Pop(); //this is the problem function, see EASX_API unsigned int GetSize(); EASX_API Value *Peek(unsigned int index); private: std::vector<Value> _stack;};IceStack.cpp
#include "IceStack.hpp"IceStack::IceStack(void){}IceStack::~IceStack(void){}void IceStack::Push(Value v){ //push the value on the stack _stack.push_back(v);}Value IceStack::Pop(){ //if the stack is not empty, pop a value of the stack and return it if(!_stack.empty()) { Value v= _stack.back(); _stack.pop_back(); return v; } //if the stack is empty, return a empty value else { return Value(); }}unsigned int IceStack::GetSize(){ //return the size return _stack.size();}Value *IceStack::Peek(unsigned int index){ //return a pointer to the value return &_stack[index];}