cpp:stack_unwinding

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
cpp:stack_unwinding [2021/05/25 07:56]
gthanos
cpp:stack_unwinding [2021/05/25 07:57]
gthanos old revision restored (2020/05/04 13:34)
Line 7: Line 7:
 #include <cstdlib> #include <cstdlib>
 using namespace std; using namespace std;
 +
 +class Vector {
 +  int *array;
 +  int size;
 +  
 +public:
 +  Vector(int length=0);
 +  ~Vector();
 +};
 +
 +Vector::Vector(int length) {
 +  cout << "Create vector of size: " << length << endl;
 +  size = length;
 +  array = new (nothrow) int[size];
 +  if(array==NULL) {
 +    cerr << "Memory allocation failure!" << endl;
 +    exit(-1);
 +  }
 +  for(int i=0; i<size; i++)
 +    array[i] = 0;
 +}
 +
 +Vector::~Vector() {
 +  cout << "~Destroying vector of size: " << size << endl;
 +  delete [] array;
 +}
 +
  
 // called by FFF() // called by FFF()
cpp/stack_unwinding.txt · Last modified: 2023/05/15 14:13 by gthanos