Wednesday 9 October 2013

reverse() and copy constructor

Reverse:

void Stack::reverse(){
Stack tmp=*this;
_top=(Node*)0;
while(!tmp.isEmpty()){
push(tmp._top->_data);
tmp.pop();
}
  }

Copy Constructor

Stack::Stack(const Stack& S){
_top=(Node*)0;
_top=S._top;
  }


Saturday 5 October 2013

Assignment #1 cio_tester, test 4.2 vs 4.17

I'm having problem with test 4.2 vs 4.17; Test 4.2 and 4.17 are exactly the same but their return key. When I get 4.2, 4.17 won't work because it returns the 'RETURN' key and my test fails. On the other hand, if i change this code to return '0', my test 4.2 will fail. the screenshot of these two tests shows there is no difference except the return key.
Test 4.2

Test 4.17


 does anyone have an idea about this? your comments on this would be great.
Thanks,