I got a array of this kind
VehicleTwoD *vehicletwod[100];
Then i create this vector
vector<VechicleTwoD*> sortVector;
Then i did this
//arrayCounter is an integer that record the element count of array vehicletwod
sortVector.assign(vehicletwod, vehicletwod+ arrayCounter);
But now i try call a function of vehicletwod by using
sortVector->getName();
It doesnt work, error message was sortVector does not have such function. how can i retrieve it or its impossible?
sortVectoris of typevector<VehicleTwoD*>(I’m assuming that’s what you meant), so it doesn’t have that method. You probably want to call the method on an element in vector, in which case you can do:which would call the method on the vector’s first element.