From: Spiritseeker Newsgroups: comp.os.msdos.djgpp Subject: How come there are five "4" in the array, when i only set four!? Date: Tue, 30 Dec 1997 03:17:00 +0100 Organization: A customer of Tele2 Lines: 95 Message-ID: <34A8599C.45D@geocities.com> NNTP-Posting-Host: mn8.swip.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cache-Post-Path: mn8!s-23470 AT dialup160-3-54 DOT swipnet DOT se To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Hello dear list, could anyone have a look at this and tell why Map.Print(); gives me five '4' instead of just four? --- layer.h --- #ifndef LAYER_H #define LAYER_H class LayerObj { private: int X_SIZE; int Y_SIZE; int *tile_data; public: LayerObj(int xsize, int ysize); ~LayerObj(void); void Assign(int x_tile, int y_tile, int newval); void Print(void); }; #endif --- layer.cpp --- #ifndef __dj_include_stdio_h_ #include #endif #include "layer.h" LayerObj::LayerObj(int xsize, int ysize) { int x,y; /* allocate memory */ tile_data = (int *) new int[ysize][xsize]; /* init variables */ X_SIZE = xsize; Y_SIZE = ysize; /* clear the array */ for(y=0;y #include "layer.h" int main(void) { LayerObj Map = LayerObj(21,20); Map.Assign(0,0,4); Map.Assign(0,16,4); Map.Assign(16,0,4); Map.Assign(16,16,4); Map.Print(); }; --- done! --- /Jonas