Question: Instructions C++ programming Your task is to write a class called Data, stored in a file named Data.h . Your class should be able to

Instructions

C++ programming

Your task is to write a class called Data, stored in a file named Data.h. Your class should be able to store a collection (vector) of integers. In addition to the appropriate constructors, your class should also have the following methods.

void add (int number); Adds a number to the data set.

void print (); Prints out the entire data set on a single line, separated by space.

void sort (); Sorts the data set in ascending order. You may implement any sorting algorithm here, for example, max sort, bubble sort, insertion sort, merge sort, quick sort, etc... There is no need to try to implement the most efficient one, any one will do. You can look at http://en.wikipedia.org/wiki/Bubble_sort for implementation details of bubble sort.

Make sure your class works as expected with the file intSort.cpp.

File do not modify only for test.

#include  #include "Data.h" int main(int argc, const char * argv[]) { Data myData; myData.add(4); myData.add(5); myData.add(2); myData.add(3); myData.add(1); myData.print(); myData.sort(); myData.print(); return 0; } 

the result output :

4 5 2 3 1 1 2 3 4 5

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!