C++ Xcode Numerical Bubble Sort Tutorial
โœ‚๐Ÿƒ๐Ÿพโ€โ™€๏ธ๐Ÿƒ๐Ÿผโ€โ™‚๏ธ
๐Ÿ“–

C++ Xcode Numerical Bubble Sort Tutorial

C++ Xcode Numerical Bubble Sort Tutorial

Here is a tutorial that uses the Xcode IDE on a Mac laptop to create a C++ desktop compiled application using a Bubble Sort method to numerically sort some numbers (ie. double).

Attempting to write code with a generic eye has the advantage that you end up with more flexibility, and, usually, more readable code.

Some ideas used in todayโ€™s code include:

  • The use of Preprocessor directives via #define identifier replacement syntax โ€ฆ will fit in with all those lovers of interpretive languages
  • The use of Command line arguments as with ./Test 22 2 15 0 โ€ฆ adds to the flexibility of your code with the user being able to tailor each usage of the executable
  • The use of a pointer to an array within a function, meaning that the data can be changed (ie. sorted) in situ rather than returning a value (or resorting to a global variable array) โ€ฆ hence we use void numerically_sort_array(double* asort, int isize = ASIZE, bool ascending = (SMODE != 0)) โ€ฆ you could change the void return, to return an error code, for example
  • The C++ use of default values in parameters of the function call, making use of the Preprocessor directives, so that the call could make sense as numerically_sort_array(psarray); as numerically_sort_array(psarray, 1000, true); โ€ฆ such thoughts come into play, in C++, also when considering Overloading
  • The deliberate pointing out of any important restriction should there be one โ€ฆ doh! โ€ฆ in that we have a stipulation for a double data type array โ€ฆ and have not implemented any Template functionality, on this occasion

Link to some downloadable C++ programming code โ€ฆ rename to mainโšซcpp for use.

If this was interesting you may be interested in this too.

This entry was posted in eLearning, Operating System, Tutorials, Xcode and tagged , , , , , , , , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *