Question: I would like to create class which can't be copied, so I put copying constructor into the private section:

```
class NotCopyable
{
public:
    NotCopyable(const double& attr1, const double& attr2) : _attr1(attr1), _attr2(attr2) {}
    ~NotCopyable(void) {}

private:
    NotCopyable& operator=(const NotCopyable&);
    NotCopyable(const NotCopyable&);
    double _attr1;
    double _attr2;
};

```

Everything is OK except when I would like to assign the array:

```
NotCopyable arr[] =
{
    NotCopyable(1, 0),
    NotCopyable(2, 3)
};

```

The compiler says that she can't access copying constructor as it is in private section.
When I put it in public section:

```
class NotCopyable
{
public:
    NotCopyable(const double& attr1, const double& attr2) : _attr1(attr1), _attr2(attr2) {}
    ~NotCopyable(void) {}
    NotCopyable(const NotCopyable&)
    {
        std::cout << "COPYING" << std:: endl;
    }
private:
    NotCopyable& operator=(const NotCopyable&);

    double _attr1;
    double _attr2;
};

```

Program compiles without errors, but copying constructor isn't called. So the question is: how do I forbid copying but still have possibility to assign arrays?

Answer: 
It is incorrect, because you use array of objects that have to be created by copying:

```
#include <vector>
using namespace std;

class NotCopyable
{
public:
    NotCopyable(const double& attr1, const double& attr2) : _attr1(attr1), _attr2(attr2) {}
    ~NotCopyable(void) {}

private:
    NotCopyable& operator=(const NotCopyable&);
    NotCopyable(const NotCopyable&);
    double _attr1;
    double _attr2;
};

int main()
{
    vector<NotCopyable> v;
    NotCopyable a(1, 2);
    v.push_back(a); // THIS IS COPYING
    return 0;
}

```

Since you have disabled copying, you can store reference only. You should make it array of **pointers**:

```
NotCopyable a(1, 2);

// incorrect:
vector<NotCopyable> v;
v.push_back(a);

// correct:
vector<NotCopyable*> v2;
v2.push_back(&a);

```

Hope this helps ;)
```
NotCopyable arr[] =
{
    NotCopyable(1, 0),
    NotCopyable(2, 3)
};

```

When you write this, the compiler needs copy-constructor, as it is *copy-initialization*. That is why you get compilation error, as the copy-constructor is declared `private`, and so it is inaccessible from outside. However, if you define it in the `public` section, then it works, but copy-constructor is not getting called, which is because of the optimization done by the compiler. The specification allows the compiler to elide the invocation of the copy-constructor in such situation, however it still needs *accessible* copy-constructor only for semantic-check of the code. It isn't actually called once the semantic check is done!