Search code examples
c++vectorprivatecopy-constructorassignment-operator

C++ stl vector for classes with private copy constructor?


There is a class in our code, say class C. I want to create a vector of objects of class C. However, both the copy constructor and assignment operator are purposely declared to be private. I don't want to (and perhaps am not allowed) to change that.

Is there any other clean way to use/define vector<C> ?


Solution

  • You could use a vector<C*> or vector<shared_ptr<C>> instead.