Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions