Quick question about types...
Just a quick question about what would be (probably) the best way to solve this.
I have 3 arrays. They are all of the same type, but have different dimensions:
And I have a simple function that returns a reference to the proper array depending on the "difficulty level":
typedef bounds_array<int, 3, 1> PointsArrayEasy;
typedef bounds_array<int, 5, 1> PointsArrayNormal;
typedef bounds_array<int, 7, 1> PointsArrayHard;
Of course this will not work. Which type should I choose to return, since they are all considered different?
PointsArray& GetReqPointsForLevelArray(Difficulty_e Difficulty)
case Easy: return g_ReqPointsForLevel_Easy;
case Normal: return g_ReqPointsForLevel_Normal;
case Hard: return g_ReqPointsForLevel_Hard;
default: assert(!"Invalid difficulty!"); return g_ReqPointsForLevel_Easy;
What would be a good way of solving such a problem?
Since Difficulty is a run-time parameter, I am guessing the correct type can only be deduced at runtime.
But then the question becomes on how to do that in a way that doesn't look like a C mess?