when I run it always appear, it stops work....
I don't know why, my classmate said it is about the memory leak problem, but he
also don't know how to fix it.
1. expensive has no user-defined destructor, so all pointers it has allocated (lines 12-16) are leaked every time an instance goes out of scope/is deleted.
2. expensive::Name and expensive::Money are initialized to arrays of unknown length, because expensive::len is not initialized at construction.
3. Lines 39, 49, and 59: Just setting expensive::len does not affect the length of the arrays pointed to by expensive::Name or expensive::Money.
4. expensive::totalexpensive() attempts to read the arrays pointed to by expensive::Name and expensive::Money up to offset 19, even though no function appears to write to these arrays past offset 12.
Overall the class is ill-defined, in my opinion. For example, expensive::getexpensive1(), expensive::getexpensive2(), and expensive::getexpensive3() should be a single function at most. It doesn't seem like the class should concern itself with I/O. I would suggest redoing it from scratch.