Debugging in Visual C++

  • Thread starter Thread starter Arash_89
  • Start date Start date
A

Arash_89

Guest
Hello,

I want to trace ms and tmp variable. I want to debugging program and see all contents in ms. but I can't see ms and tmp.


Thanks

1579734.jpg


#include <iostream>
#include <assert.h>

using namespace std;

class MyStack {
public:
MyStack() {
max_len = 1000;
value = new int[max_len];
}
MyStack(unsigned int len) {
max_len = len;
value = new int[max_len];
}
bool isEmpty() {
if (index == 0) return true; else return false;
}
unsigned int _size() {
return index;
}
bool isFull() {
if (index == max_len) return true; else return false;
}
void push(int i) {
assert(!isFull());
value[index] = i;
index++;
}
int last() {
assert(index > 0);
return value[index - 1];
}
int pop() {
assert(!isEmpty());
index--;
return value[index];
}
~MyStack() {
delete[] value;
}
private:
unsigned int index = 0, max_len;
int* value;
};
int main()
{
cout << "n= ";
int n;
cin >> n;
MyStack ms(n);
MyStack tmp(n);
for (int z1 = 0; z1 < n; z1++)
{
cout << z1 << ":";
int j;
cin >> j;
ms.push(j);
}
while (tmp._size() < n) {
int z1 = ms.pop();
while (!tmp.isEmpty() && z1 > tmp.last())
{
ms.push(tmp.pop());
}
tmp.push(z1);
}
while (!tmp.isEmpty())
{
cout << tmp.pop() << endl;
}
return 0;
}

Continue reading...
 
Back
Top