• Advertisement
Sign in to follow this  

if and array checking

This topic is 1861 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

bool bricks[3][5]={false};

I am trying to check a Boolean array.

the error I am getting is that bricks has to be an lvalue.

if(bricks[2][5]=true)

I know this is very simple, but google is not working very well.

Share this post


Link to post
Share on other sites
Advertisement
Can you show actual code, as typed?

It sounds like your array might be declared as bool *bricks[3][5] or you are doing something like if(bricks[2]==true), in which case you are comparing a bool (true) with a pointer to bool.

Share this post


Link to post
Share on other sites

bool bricks[3][5]={{false,false,false,false,false},{false,false,false,false,false},{false,false,false,false,false}};
void brick_collision()
{
if(bricks[2,4]==true)
{

}


}

here is some of my code

Share this post


Link to post
Share on other sites
To elaborate a bit: bricks[2,4] is still valid C++, take a look at http://en.wikipedia.org/wiki/Comma_operator.

What it actually does is discard the value of 2 and use 4 as the array subscript. As a result, bricks[2,4] evaluates to bricks[4], which is of type bool[5], thus the incompatibility error. Edited by rnlf

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement