isit ok using *this pointer

This is a discussion on isit ok using *this pointer within the C++ Programming forums, part of the General Programming Boards category; Code:
void GetItem()
{
for (int iii=0; iii!=MAX_INV; iii++)
if (charInv[iii].id==0){ charInv[iii] = *this); break;}
else if (charInv[iii].id==id)
if (amount ...

It will make a copy of the current object, so sure.
You could also store a pointer to the object, but then you must beware of dangling pointer issues if the object goes out of scope.
Your indentation needs work, too, if I may say so (too many spaces/tabs for indentation).
Especially, you should put the ending } on a separate line. It makes it much more readable.

It will make a copy of the current object, so sure.
You could also store a pointer to the object, but then you must beware of dangling pointer issues if the object goes out of scope.
Your indentation needs work, too, if I may say so (too many spaces/tabs for indentation).
Especially, you should put the ending } on a separate line. It makes it much more readable.

It will make a copy of the current object, so sure.
You could also store a pointer to the object, but then you must beware of dangling pointer issues if the object goes out of scope.
Your indentation needs work, too, if I may say so (too many spaces/tabs for indentation).
Especially, you should put the ending } on a separate line. It makes it much more readable.