Hey guys,
I cannot for the life of me figure out how to call an object in the main. The object that needs to be used must be made available throughout the program, but is only accessible in the function that created it.
I've looked up a series of different solutions, but none of them fit my needs.
Here's the code.
Any help would be appreciated. Thank you!
I cannot for the life of me figure out how to call an object in the main. The object that needs to be used must be made available throughout the program, but is only accessible in the function that created it.
I've looked up a series of different solutions, but none of them fit my needs.
Here's the code.
void createVehicleDB()
{
int numberLines = 0;
ifstream fi;
fi.open("vehicles.txt");
fi >> numberLines;
VEHICLE * vehicle = new VEHICLE[numberLines]; //all vehicle objects are only accessible in createVehicleDB() :(/>
....
fi.clear(); //clear file stream
fi.close(); //close file stream
}
void main()
{
createVehicleDB();
mainMenu();
cout << vehicle[0].model; // Need to be able to call this.
}
Any help would be appreciated. Thank you!