Welcome! Log In Create A New Profile

Advanced

sad smiley inherited function and sort function

Posted by kiolb 
Announcements Last Post
Announcement : Programming Students at UNISA School of Computing 06/19/2019 02:01PM
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
avatar sad smiley inherited function and sort function
October 09, 2008 11:21AM
1) If using the class orderedLinkedListType, which has inherited functions that insert items at the first and last positions from the base class, which will mess with the ordered list. How can these functions be blocked? Or must I just redefine them to call the ordered insert function in the class orderedLinkedListType

2) Why would a sort function be used in an ordered class?? (Malik from pg572)
Because the items are added in the correct order. Surely the sort functions should be in the unordered array and linked list base classes.

Thanks
B
avatar sad smiley Re: inherited function and sort function
October 15, 2008 10:55AM
Other things wrong with malik's functions.

1) 'last' is not set when required on the linked sort functions. (insertion pg577 and merge pg591) Not sure how to solve with merge, other than create another function that uses current and trailCurrent until the null pointer is reached and set 'last' to trailCurrent. Any other ideas?

2) insert into a binary search tree checks for duplicates. If found does not release the memory allocated with new at the begining of the function. (pg657) Is that not a memory leak?? I rewote the function. I will post if required.

regards
B
avatar sad smiley Re: inherited function and sort function
October 16, 2008 08:55PM
Yeah, I've also picked up quite a few little errors here and there. I think that's one of the reasons I'm glad I didn't use any of his code this year. I've preferred just to code it all myself and make look at his classes just as a means of comparison.

I agree with what you've said though. I think his code leaks in a few places, and when he's writing other functions he forgets to reassign first and last and other silly things.

-Valkeye
Sorry, only registered users may post in this forum.

Click here to login