Whenever you declare a variable inside a class method with the same name as a data member, that variable hides the data member. The
variables defined insidethe body of your constructors serves no purpose, and the one in operator=
means the operator does nothing visible to client code.
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
In C++ you should prefer to use std::copy
. 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
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.