Help! I really haven't got these array things sussed out at all 
Author Message
 Help! I really haven't got these array things sussed out at all

I looked up the syntax for declaring 2D arrays in MSDN and got

#define IMAGEDIMENSION 1024
        int  (*OutputImage)[IMAGEDIMENSION];

so I can use

        OutputImage=new int[IMAGEDIMENSION][IMAGEDIMENSION];
and
        delete []OutputImage;

(which seems to work. It doesn't chuck exceptions everywhere anyway)

but can I do the same thing with a 1D array? Can I bu**ery.

#define MAXLAYERS 10
        Layers *pm_ImageLayers[MAXLAYERS];

means I can't do

        pm_ImageLayers=new Layers[MAXLAYERS];
( cannot convert from 'struct Layers *' to 'struct Layers *[10])

+ the many permutations of square brackets positions that I've tried.
Of course
        for(count=0 etc;;) p_pointer[count]=new thingy;

works but is a bit tedious.

Thanks for any help.

Cheers

Z



Sun, 11 Sep 2005 17:59:25 GMT  
 Help! I really haven't got these array things sussed out at all
Try

         #define MAXLAYERS 10
        Layers *pm_ImageLayers;

        pm_ImageLayers= new Layers[MAXLAYERS];
        //    Do your stuff

        delete[] pm_ImageLayers;

--
Cheers
Check Abdoul [ VC++ MVP ]
-----------------------------------


Quote:

> I looked up the syntax for declaring 2D arrays in MSDN and got

> #define IMAGEDIMENSION 1024
> int  (*OutputImage)[IMAGEDIMENSION];

> so I can use

> OutputImage=new int[IMAGEDIMENSION][IMAGEDIMENSION];
> and
> delete []OutputImage;

> (which seems to work. It doesn't chuck exceptions everywhere anyway)

> but can I do the same thing with a 1D array? Can I bu**ery.

> #define MAXLAYERS 10
> Layers *pm_ImageLayers[MAXLAYERS];

> means I can't do

> pm_ImageLayers=new Layers[MAXLAYERS];
> ( cannot convert from 'struct Layers *' to 'struct Layers *[10])

> + the many permutations of square brackets positions that I've tried.
> Of course
> for(count=0 etc;;) p_pointer[count]=new thingy;

> works but is a bit tedious.

> Thanks for any help.

> Cheers

> Z



Sun, 11 Sep 2005 18:22:28 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. One thing in BASIC which I haven't

2. Really whacky things in VS.NET [MS HELP!!]

3. Message loop seems haven't been initialized when using CWinThread

4. Message loop seems haven't been initialized when using CWinThread

5. REALLY need help getting started with CryptAPI

6. Really Easy Help needed Managed c++ syntax for declaring array of unsigned long

7. Help making a really big array needed

8. who can help me ,I really don't know why

9. does 'save as' dialog really work

10. Checksums of a.outs

11. I'm really, really, really new at this.

12. Colour print outs of source code ?

 

 
Powered by phpBB® Forum Software