Class Car{
Private:
string* _ID;
bool _isFaulty;
int _location;
int _timer;
int _order;
vector<Road*> _roadPlan;
}
I want to implements Copy constructor (deep copy) and destructor, and I don't know how to treat the vector of pointers (Road is an object too)
It's my first time with c++. Any help would be greatly appreciated!
Mor
Another thing, maybe I'll prefer using List instead of Vector, so i would like to see an implements of Copy constructor and destuctor with List too,
Thank you!!!
You'll need to loop too. Also, you can't just delete _roadPlan, it's an object (a vector) not a pointer.
you'll need to loop through and delete each pointer it holds, and if you're finicky also call vector::erase() for each one (or wait til the loop is done and call vector::clear())
Your code is gone (bad form), so I can't see how _ID is used, but I doubt it needs to be a pointer.
Also try not to start variable names with underscore (_), many system entities start their variable names that way, and you're more likely to have a name-clash with one of them.