Hello i got this code which is working fine but i fail to understand some parts of it and i could really use some help if anyone has some time to spare. I dont understand why is there a pointer *hightway on vector and why is there a star in vector? None of the vectors i found use stars. Even the slightest of help is welcome, thanks in advance.
int main() {
int menuSelection,entryPoint,exitPoint,vehicleType;
string plate,entryTime,exitTime;
Vehicle * v = NULL;
vector<Vehicle *> * highway;
highway = new vector<Vehicle*>;
do {
mainMenu:
cout << "\n\n\tKENTPIKO MENOY\n";
cout << "\t[1] Eisodos oximatos\n";
cout << "\t[2] Eksodos oximatos\n";
cout << "\t[0] Eksodos apo to programma\n\n";
cout << "\tEpilogi: ";
cin >> menuSelection;
switch(menuSelection) {
case 0:
cout << "\n\nEuxaristoume pou xrisimopoihsate to programma mas!";
return 0;
case 1:
cout << "\n\n\tEISODOS OXIMATOS";
do {
cout << "\n\tSe poio simeio briskeste ; (1 ews 3) \t";
cin >> entryPoint;
} while(entryPoint > 3 || entryPoint == 0);
cout << "\n\tArithmos kukloforias: ";
cin >> plate;
cout << "\n\tTupos oximatos\t";
cout << "\n\t1: Dikikla\t2:Autokinita\t3:Fortiga\n";
do {
cout << "\tEpilogi: ";
cin >> vehicleType;
}while (vehicleType > 3 || vehicleType == 0);
cout << endl;
if (vehicleType==1){
v = new Motorcycle();
}
else if (vehicleType==2){
v = new Car();
}
else if (vehicleType==3){
v = new Truck();
}
v->setPlate(plate);
v->setEntryPoint(entryPoint);
v->setEntryTime(getTime());
highway->push_back(v);
cout << "\n\n\tTo autokinito mpike stis " << v->getEntryTime() << " apo to simeio " << v->getEntryPoint();
cout << "\n\n\tParakalo paralabate to eisitirio";
v = 0;
goto mainMenu;
case 2:
cout << "\n\n\tEKSODOS OXIMATOS";
cout << "\n\tArithmos kukloforias: ";
cin >> plate;
for(vector<Vehicle*>::iterator it = highway->begin(); it != highway->end(); it++){
if (plate.compare((*it)->getPlate()) == 0){
do {
cout << "\n\tSe poio shmeio briskeste; (" << (*it)->getEntryPoint()+1 <<" ews 4) \t";
cin >> exitPoint;
}while(exitPoint > 4 || exitPoint <= (*it)->getEntryPoint());
(*it)->setExitPoint(exitPoint);
(*it)->setExitTime(getTime());
cout << "\tArithmos kukloforias: " << (*it)->getPlate() << endl << endl;
cout << "\tSimeio eisodou: " << (*it)->getEntryPoint() << endl;
cout << "\tOra eisodou : " << (*it)->getEntryTime() << endl;
cout << "\tSimeio eksodou : " << (*it)->getExitPoint() << endl;
cout << "\tOra eksodou : " << (*it)->getExitTime() << endl << endl;
cout << "\tSinoliki apostasi: " << (*it)->totalDistance() << "km"<< endl;
double km;
km=(*it)->totalFee()/(*it)->totalDistance();
cout << "\n\tkostos ana klm: " << km;
cout << "\n\n\tSINOLIKO POSO: " << (*it)->totalFee();
cout << "\n\n\tH apodeiksi einai ston ektupoti";
}
else {
cout << "\n\nTO OXIMA DEN YPARXEI!" << endl;
break;
}
}
goto mainMenu;
default:
cout << "\n\n\tLATHOS EPILOGI! Dokimaste ksana.\n\n";
goto mainMenu;
}
} while (menuSelection != 0);
return 0;
}