I am new to computer science and I guess this has something to do with hash function.
I have a class in cpp:
class Car{
public:
int fleetId;
OwnershipEnum owner;
int buildDate;
bool hasFourDoors;
... with many other members
};
Now, my problem is, how to 'scientifically' generate an integer key based on the 4 members I list?
I can think of a simple way, 10000*int(fleetId) + 1000 * int(owner) + 100×int(buildDate) + int(hasFourDoors)
I think ideally the key is continuous, so I can store all the Car objects in an array and use this generated key to DIRECTLY access the car object.
***** as per the comments: the cars are all different, there is no identical cars ********
***** these four members are static: they won't change after being created *****
Can anyone point me to the right solution here?
Thanks