Whenever you declare a variable inside a class method with the same name as a data member, that variable hides the data member. The
double a[20];
variables defined insidethe body of your constructors serves no purpose, and the one in
operator= means the operator does nothing visible to client code.
print_array should only print the elements of
a that have been used in the array.
Your copy constructor is incorrect. It does not copy any of the elements of the array that is to be copied.
What purpose does the member
max_number serve?
In C++ you should prefer to use
std::copy over
std::memcpy. You lose type safety with
memcpy (as may be evidenced by your incorrect arguments to the function.) Your
operator= does not properly set the
number_used or
max_number members of your class. Also,
operator= should return a reference to
PartFilledArray.
The problem, of course, using
delete[] in your destructor is that you can't use
delete[] on memory which has not been allocated with
new[].
I would strongly suggest implementing your type in incremental ways and testing what you've done before you try to many different methods that depend on each other when you aren't sure that any of them work.
http://ideone.com/5rxCEM