I try to implement copy on write using a pointer on integer. But I don't understand how to write the code. The idea is very clear in my head: when I use the default constructor, I create a new instance of the object (number of instances=1) and when I use the copy constructor, I increment the number of instances and make a shallow copy of the object.

```
    class Myclass
{
public:
    Myclass(const char * foo, int foo2) : foo(foo), foo2(foo2) 
    {
        (*ref)=1;
    }
    Myclass(const Myclass& rhs) :foo(rhs.foo),foo2(rhs.foo2) 
    {
        (*ref)++;
    }
    const char * foo;
    int foo2;
    int *ref;
};

```

I begin with C++ and the notion of pointer is completely news for me so I tried this. 
But I really don't understand why "ref" is still equal to 1 even if I create a copy of the object witht he copy constructor.