sss f f
Last edited on
seems like there may be an issue in method: [inventory::AddItem] on line 114:
newNode->meti = aItem
you are copying an instance of object item [aItem] too the newNode's item instance [meti].
this could cause issues as your item class does not overload the equal operator - this is required for your item class since it has a dynamic portion - the name field.
this field is a pointer to a char, so without overloading the equal operator, we would only be copying the pointer address value of aItem to meti and not the contents that aItem points to.
typically when one overloads the [ = ] operator, you also use it in your copy constructor. your copy constructor does not copy the name field of the object to be copied from - it discards it.
Thank you so much! That was exactly what I needed.
I am still a beginner programmer, but I'm doing my best here.
Thanks again for the help.
you're welcome and I'm glad that the advice worked for you.
i'm also impressed with your level for a beginner programmer (working with raw pointers, knowing when to delete it, and understanding classes + concept of operator overloading ...)
keep up the good work.