I'm trying to make a class using enumerated values for a position of a sensor and I am using vectors with a type int as the input for this function, and I want an enumerated value out. I'm not sure if this code will work or not. I'm not quite sure how to test it.
#include <vector>
place getPos(vector<int>& pin)
{
int i;
for(i = 0; i <= sizeof(pin); i++)
{
if (pin[i])
break;
}
place castEnum = (place)i;
return castEnum;
}
So this is the update as far as I can gather:
#include <vector>
place getPos(vector<int>& pin)
{
int i;
for(i = 0; i <= pin.size(); i++)
{
if (pin[i])
break;
}
return static_cast <place> (i);
}