// 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 <cstring>

using namespace std;

class X
{
    private:
        char *p;
    public:
        X() { p = new char[3]; cout << (long)p << " new" << endl; strcpy(p, "X"); }
        ~X() { cout << (long)p << " delete" << endl; delete[] p; }
        void M() { cout << (long)p << " use" << endl; cout << p << endl; }
        void operator=(const class X& o) { strcpy(p, o.p); }
};

int main()
{
    X *a = new X[3];
    X *b = new X[2];
    for(int i = 0; i < 2; i++) b[i] = a[i];
    delete[] a;
    for(int i = 0; i < 2; i++) b[i].M();
    delete[] b;
    return 0;
}
