Sign in to follow this  
xx6heartless6xx

= Operator Not Working

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.

[code]
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
}
}
[/code]

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

Share this post


Link to post
Share on other sites
BitMaster    8651
tiles[i] 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.
[code]tiles[i] = Tile(...);[/code]
should do the job.

Share this post


Link to post
Share on other sites
rip-off    10976
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
[quote name='BitMaster' timestamp='1310542532' post='4834655']
tiles[i] 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.
[code]tiles[i] = Tile(...);[/code]
should do the job.
[/quote]

That was it! Thanks for the help

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this