Original Post
Alright, I've finally got my overloaded = operator to work, except for one final problem: how can you check to see if the source object is valid? Here's the code: Any ideas? Thanks, The Joshinator
CTile& CTile::operator =(CTile &src_tile)
{
// This function overloads the = operator so we can copy tiles correctly; *this is the left-hand operand(dest)
// and src_tile is the right-hand operand(src)
//****************************************************************************//
// This works for the destination validation
// Check if the left operand is valid
if (!this)
return *this; // it's not, so return the pointer
// Seems like it should work, but compiler complains that the ! operator isn't defined for CTile. Should I define it and do it this way?
// Check if the right operand is valid
if (!src_tile)
return *this; // it's not valid, so return the pointer
// This compiles, but doesn't work...dunno why :-S
if (!&src_tile)
return *this; // it's not valid, so return the pointer
//contents of function...blah blah
// return pointer to existing object
return *this;
} // end CTile::operator=();