Thread: 2 dimentional array of pointers

  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    1

    Unhappy 2 dimentional array of pointers

    Hi everyone,

    I'm trying to make a c++ stratego game, It's going to be the first quality game i make so i'm trying to make it as good as possible but i'm still a newB in making games I'm hoping I'm doing the right stuff!

    But enough, the point is: I want to make an array of 10 x 10 with pointers, for the playing field, empty fields all point to a empty play piece [as good as ZERO] and if there's a play piece, example a bomb, i want it to point at the bomb. The thing is also that all there are 6 bomb for each player so i placed the bombs in an array like this:

    int MAX_BOMB = 6;
    piece *_bomb;
    _bomb = new piece[MAX_BOMB]();

    As you can see, the _bomb pointer points to the list of bombs and i want to add another pointer that points to lets say the 2nd element of the _bomb array, the 2nd bomb, and that pointer must be stored in the multidimentional field array.

    Well, thats about it i guess, maybe there's even a smarter, more eficient way of doing this. Please let me know!

    Thank's Cerber4s

  2. #2
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Code:
    field[0][0]=(_bomb+1) //Places pointer to second bomb in the field
    Is that what you mean?

    EDIT: Use code tags please.
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 07-11-2008, 07:39 AM
  2. How to sort an array of pointers to structure
    By broli86 in forum C Programming
    Replies: 3
    Last Post: 06-30-2008, 02:52 PM
  3. Returning an Array of Pointers to Objects
    By randomalias in forum C++ Programming
    Replies: 4
    Last Post: 04-29-2006, 02:45 PM
  4. Passing pointers between functions
    By heygirls_uk in forum C Programming
    Replies: 5
    Last Post: 01-09-2004, 06:58 PM
  5. array of pointers to struct array
    By eth0 in forum C++ Programming
    Replies: 1
    Last Post: 01-08-2004, 06:43 PM