Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #12368

A bit of an pointer to array of pointers problem

From "A" <a@a.a>
Newsgroups comp.lang.c++
Subject A bit of an pointer to array of pointers problem
Date 2011-12-11 23:48 +0100
Organization B.net Hrvatska d.o.o.
Message-ID <jc3c0v$o8q$1@gregory.bnet.hr> (permalink)

Show all headers | View raw


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[i]...
    }

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? 

Back to comp.lang.c++ | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

A bit of an pointer to array of pointers problem "A" <a@a.a> - 2011-12-11 23:48 +0100
  Re: A bit of an pointer to array of pointers problem "A" <a@a.a> - 2011-12-11 23:50 +0100
  Re: A bit of an pointer to array of pointers problem "A" <a@a.a> - 2011-12-11 23:56 +0100
    Re: A bit of an pointer to array of pointers problem Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2011-12-11 19:29 -0500
      Re: A bit of an pointer to array of pointers problem "A" <a@a.a> - 2011-12-12 04:19 +0100
        Re: A bit of an pointer to array of pointers problem Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2011-12-11 23:48 -0500

csiph-web