### sort array

so i am new to C+ and i need help understanding and doing an assignment.
Here is the assignment:

Create a class called SortArray;
Your class has a property for an array of size 10. It also has functions or methods. Initialize the array to a set of random integers. Write a function called moveUP that takes the number with the lowest value and moves it to the top of the array (position 0).
It has it written out pretty well for you. Create a class that has an array member of size 10. Either init the array in the constructor or write a function to do it. Then write a function that finds the smallest element of the array, and swap places with the 0th element.
i don't know how to create a class
Paying attention in class generally helps. Anyways:
http://www.cplusplus.com/doc/tutorial/classes/

 ``12345678910`` ``````class SortArray { public: SortArray(); void sampleMethod(); private: int sampleMember; };``````

Should be enough to get you started.
Hey here's a little reference..."bubble sort algorithm"

 ``12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182`` ``````#include "iostream" #include #include using std::cout; using std::endl; ///Sort Array Class class SortArray { private: int randomArrayOfTen[10]; public: void MoveUp(); void OutputNumbers(); void GenerateRandomNumbers(); }; int main() { SortArray cSort; srand(time(0)); ///Gets ten random numbers from 1 through 100 cSort.GenerateRandomNumbers(); cout<<"The numbers before they are sorted"< randomArrayOfTen[numberAbove]) { ///Puts Lesser Value Into A Placeholder placeHolder = randomArrayOfTen[numberAbove]; ///Puts Bigger Value In Upper Position randomArrayOfTen[numberAbove] = randomArrayOfTen[g]; ///Puts Lesser Value in Lower Position randomArrayOfTen[g] = placeHolder; } } } } void SortArray::GenerateRandomNumbers() { for(int i=0; i<10; i++) { randomArrayOfTen[i] = rand() % 100 + 1; } } void SortArray::OutputNumbers() { for(int j=0; j<10; j++) { cout<

Topic archived. No new replies allowed.