i know i don't need to overload the = operator because of memberwise assignment but i was wondering why this code will work correctly if i dont overload the = operator and not work correctly if i don't overload it. I'm pretty sure i wrote the code right for it but i don't get why it doesn't work.
Your assignment operator does almost nothing that the default doesn't already do, so it should work just fine.
Define "doesn't work". Compiler error? Program crash? what?
The only thing I see is that you're returning an object copy from your assignment operator (when typically you should return a reference). But since you don't have a copy ctor I don't see why that would matter.
alright i don't know why it was'nt working before but it works now. Before it would compile and run just fine but i would get different answers when inputting the same data (compared to not using the overloaded = operator)
Yeah it'll work. It's just mostly a performance thing.
Returning by value returns a copy. This potentially creates another object, copies data to it, then (if it's not used) destroys it. Since the return value of assignment operators are rarely used, it's kind of a waste.