// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
#include <iostream>
#include <cstdlib>

using namespace std;

class X
{
    public:
        X() { cout << "Constructor called" << endl; }
        ~X() { cout << "Destructor called" << endl; }
};

int main()
{
    cout << "malloc & free" << endl;
    X *o1 = (X *)malloc(sizeof(X));
    free(o1);
    X *a1 = (X *)malloc(3*sizeof(X));
    free(a1);
    cout << "new & delete" << endl;
    X *o2 = new X();
    delete o2;
    X *a2 = new X[3];
    delete[] a2;
    return 0;
}
