hi, I am getting runtimes errors sometimes and cant figure out why, that i am pointing on wrong memory.
i have got this terrible interface. I think there can be problem with saving objects to vector and my copy constructor, or iterator. And i am not sure if i am saving those files correctly.
Thanks for any help.
I have class Airport which has vector of planes.
Code:vector<plane> planes; vector<plane>::iterator planeIterator; bool airport::addPlane(const plane& p) //funcction to add planes into vector { if(planes.empty()) { planes.push_back(p); planeIterator = planes.begin(); //if vector empty put iterator on first object } else { planes.push_back(p); } return true; } const plane* airport::getCurrentPlane() const // get the current object on which is iterator pointing has to be const pointer on plane { if(planes.size()== 0) { return NULL; } plane *p1 = new plane(*planeIterator); return p1; } //here is my copy constructor from plane class plane::plane(const plane& other) { _name=other.getName(); other.getPosition(_x,_y); _direction=other.getDirection(); _hasLanded = other._hasLanded; }



LinkBack URL
About LinkBacks



