Thursday, 15 August 2013

encapsulation - How would I encapsulate a mergesort program for general customer use in C++? -



encapsulation - How would I encapsulate a mergesort program for general customer use in C++? -

i have mergesort accepts list of ints , makes array out of them, sorts them, , prints out sorted array. of code in single .cpp file.

what way provide code wants sort array of user defined objects?

my instincts provide virtual method file (interface) , require user override comparing operators , read/write methods.

would best move away arrays , utilize linked list?

if vague/subjective slap me around , close it. wanted ideas beyond own.

use templates implement sort , utilize pointer array instead of array of objects inquire functor implements comparing , provide default functor uses < operator comparison.

c++ encapsulation mergesort

No comments:

Post a Comment