Jump to content
  • Advertisement
Sign in to follow this  
xx6heartless6xx

= Operator Not Working

This topic is 2706 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

In a function of mine, I would like to run this for loop and create a new Tile Object after each iteration, but I get this error which says no operator '=' matches these operands. I have the error posted under the code. I do not know what is wrong and yes I have "Tile.h" included.


void function( Tile* tiles ) {
for( int i = 0; i < tiles->get_TOTAL_TILES(); i++ ) {
if( ( tileType >= 0 ) && ( tileType < tiles->get_TILE_SPRITES() ) )
tiles[ i ] = new Tile( ... ); // error here
}
}



error C2679: binary '=' : no operator found which takes a right-hand operand of type 'Tile *' (or there is no acceptable conversion)

Share this post


Link to post
Share on other sites
Advertisement
tiles is of type Tile. You are trying to assign a Tile* to it, which in general will not work and practically always is a horrible idea anyway.
tiles = Tile(...);
should do the job.

Share this post


Link to post
Share on other sites
I would also be wary of how you are calling get_TOTAL_TILES and get_TILE_SPRITES. These should either be constants in the Tile class, or variables in a "wrapping" class such as Map.

Share this post


Link to post
Share on other sites

tiles is of type Tile. You are trying to assign a Tile* to it, which in general will not work and practically always is a horrible idea anyway.
tiles = Tile(...);
should do the job.


That was it! Thanks for the help

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!