A
A
Here is a situation:
TCustomObject *pObjA[] = { Obj1, Obj2, Obj3 };
TCustomObject *pObjB[] = { Obj4, Obj5, Obj6 };
TCustomObject *pObjC[] = { Obj7, Obj8, Obj9 };
for (int i = 0; i < ( sizeof(pObjA) / sizeof(pObjA[0]) ); i++)
{
// do something with pObjA...
}
How would you add a pointer to array of pointers so that if a code needs
array A array (Obj1, Obj2 and Obj3)
but if it needs B or C it needs Obj4-6 or Obj7-9?
If I put a pointer to a pointer like this:
TCustomObject **pObjUsed = pObjA;
Then to get Obj1 I would need to do something like:
pObjUsed-> (here use Obj1)
How would you rewrite this for for loop to be able to use any of 3 arrays?
TCustomObject *pObjA[] = { Obj1, Obj2, Obj3 };
TCustomObject *pObjB[] = { Obj4, Obj5, Obj6 };
TCustomObject *pObjC[] = { Obj7, Obj8, Obj9 };
for (int i = 0; i < ( sizeof(pObjA) / sizeof(pObjA[0]) ); i++)
{
// do something with pObjA...
}
How would you add a pointer to array of pointers so that if a code needs
array A array (Obj1, Obj2 and Obj3)
but if it needs B or C it needs Obj4-6 or Obj7-9?
If I put a pointer to a pointer like this:
TCustomObject **pObjUsed = pObjA;
Then to get Obj1 I would need to do something like:
pObjUsed-> (here use Obj1)
How would you rewrite this for for loop to be able to use any of 3 arrays?