Original Post
I'm coding in C++ in a Visual Studio .Net environment.
I have a simple stack declared in my program:
std::stack<object*> objStack;
Nothing wrong there..
Now, this is the code where I encounter a problem.
//the stacks size == 0
if(something == "yes")
{
Object* newObj = new Object();
objStack.push(newObj);
}
//the stacks size == 1
if(something == "no")
{
objStack.pop();
}
//the stacks size == 0
Looking at this code, its very basic and everything seems fine. But what I see happening in the Watch List of values is that right after the program steps into the yes block and the object is pushed onto the stack, even though the program never seems to enter the no block, the stack still seems to pop and the size then equals 0. When I comment out the objStack.pop() line, then the stack's size remains 1. I've even tried putting this as a test:
if(2 == 4)
{
objStack.pop();
}
which is always false, yet I still get the same exact result. This is driving me insane, it just doesnt make any sense..
[edited by - TheJakub on May 30, 2003 3:49:37 PM]
[edited by - TheJakub on May 30, 2003 3:50:00 PM]