cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/23/17:32:21

From: nil AT hem1 DOT passagen DOT se (Nicklas Lindgren)
Newsgroups: comp.os.msdos.djgpp
Subject: Problem with array of pointers
Date: Tue, 23 Jun 1998 21:28:03 GMT
Organization: Algonet/Tninet
Lines: 33
Message-ID: <35901de1.23132201@news.algonet.se>
NNTP-Posting-Host: du206-242.ppp.algonet.se
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hello everybody.

I have run into a problem when using an array of pointers
I declared it:

GameSprite *gsprite[SPRITES];

SPRITES is an const int. GameSprite is a class. (I think this makes an
array of pointers, i'm not positively sure about that.)

Anyway, i initialize them all:

  for(x=0; x<SPRITES; x++) {
    gsprite[x] = new GameSprite();
  }

Then they are used in a loop:

    for(x=0; x<SPRITES; x++) {
      if(gsprite[x] != NULL) {
        gsprite[x]->Plot();
      }
    }

The problem: The loop works once, the second time the last pointer in
the array just points to garbage. The problem doesn't seem to occur
when SPRITES is less than 255.

If anybody could help, i would be really greatful.

	Nicklas Lindgren <nil AT hem1 DOT passagen DOT se>


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019