const id generated by static variable

Hi!
I have this class:
class Doctor
{
private:
const int codP;// incremented in implicit and copy constructors
static int cod; // outline initialized with 0
}
And a vector of Doctor objects in other class. How can I conserve the id ? Because when I delete the dynamic vector and reallocate memory for it the id is incremented...
Last edited on
Create a copy constructor that preserves the id.
If you're using std::vector the reallocation will use the copy constructor (or move constructor if there is one) so as long as the copy constructor doesn't increment anything, just copy, there shouldn't be a problem.
Topic archived. No new replies allowed.