[cs13001] Lab11
    Mikhail Nesterenko 
    mikhail at cs.kent.edu
       
    Tue Apr  2 11:57:32 EDT 2013
    
    
  
> 
> I have a question about the conversation of the output function in
> lab 10 to the output member function in lab 11.  In the standalone
> function we implemented the remove number function to delete a
> temporary array while printing the smallest number each iteration.
> Since remove number is now a member method which can only be called
> on an object of our class, should we create a "new" object of our
> class, assign it to "this ",( to use in the printing of the elements
> of our object's array), then call remove number on this temporary
> object?  I've been trying to work it out this way and I believe the
> destructor is screwing with the temp object each loop iteration.  If
> there is a better method , please enlighten me.
A method, just like a standalone function, is allowed to have local
variables.
So you can apply the logic of Lab 10 to Lab 11. That is, in
varArray::removeNumber() method you declare a local (automatic)
pointer to a temporary array. Dynamically allocate this array, copy
values to this array and then proceed to remove them in sorted order.
You might consider turning this copy function into a (private) member.
Thanks,
-- 
Mikhail
    
    
More information about the cs13001
mailing list