• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Static data?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Static data?


  • Subject: Re: Static data?
  • From: "Philip" <email@hidden>
  • Date: Wed, 7 Jul 2004 00:25:13 -0700

> > So, now, the previous post confused me. What is the _correct way of
> > doing this:
> >
> > int foo[1024][1024][1024];
> >
> > dynamically?

I would recommend the the following C++ syntax; it comes with limited type
checking:
    // declare var and allocate
    int (*array) [1024][1024] = new int [1024][1024][1024];

    // then use the array like...
    array[10][10][10]   = 12;

    // the following line generates a compiler error; wrong type
    array[10][10] = 12;

    // and dispose of the array like...
    delete [] array;

    // alternatively, you can make the first dimension a variable:
    int dimension = 1024;
    int (*array1) [1024][1024] = new int [dimension][1024][1024];

    enjoy.
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.


  • Prev by Date: Re: Disabling a Processor
  • Next by Date: Re: Static data?
  • Previous by thread: Re: Static data?
  • Next by thread: Re: Static data?
  • Index(es):
    • Date
    • Thread