Public Group

# = Operator Not Working

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

## 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 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.

##### 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 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

1. 1
2. 2
3. 3
4. 4
Rutin
11
5. 5

• 12
• 19
• 10
• 14
• 10
• ### Forum Statistics

• Total Topics
632665
• Total Posts
3007712
• ### Who's Online (See full list)

There are no registered users currently online

×