www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/03/22/12:01:51

Newsgroups: alt.comp.lang.learn.c-c++,comp.os.msdos.djgpp
Subject: Re: Problem with int[][]
From: xnews DOT public DOT home AT bogus DOT rtij DOT nl (Martijn Lievaart)
References: <oQgu6.512$I81 DOT 4799 AT nntp1 DOT chello DOT se>
Organization: TINC
Message-ID: <Xns906CB5C31176Cyoudontwannaknow@194.109.133.13>
User-Agent: Xnews/4.01.30
X-Memorial: To Herbs, where ever you are
Date: 22 Mar 2001 16:51:32 GMT
Lines: 35
NNTP-Posting-Host: 212.64.34.251
X-Trace: 985279892 dreader2.news.xs4all.nl 151 martijnl/212.64.34.251
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

"Daniel Eliasson" <danieleliasson AT chello DOT se> wrote in
<oQgu6.512$I81 DOT 4799 AT nntp1 DOT chello DOT se>: 

>I keep getting these messages when I use my array:
>
>player.cpp:55: invalid types `int[int]' for array subscript
>player.cpp:57: invalid types `int[int]' for array subscript
>
>
>The code looks like this:
>
> for(int i = 0; i < GRIDSIZE; i++)
> {
>     for(int j = 0; j < GRIDSIZE; j++)
>     {
>  if(map[i][j] == GRID_PLAYER)  // It's complaining about these
>  {
>      map[i][j] = GRID_EMPTY;  // It's complaining about these
>  }
>     }
> }
>
>Does anyone know what's wrong? I define map like this:
>int map[GRIDSIZE][GRIDSIZE];
>
>(GRIDSIZE is a const int with the value of 128 (const int GRIDSIZE =
>128;)) 
>

map is a reserved identifier (in namespace std, but your compiler may not 
support that yet). Try renaming map to something else, and see if the 
problem goes away.

HTH,
M4

- Raw text -


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