1- Implement an abstract class Arrays that has the following pure virtual functi
ID: 3909275 • Letter: 1
Question
1- Implement an abstract class Arrays that has the following pure virtual functions typel), that returns the type of the array (1-dimensional or 2-dimensional). i) sie0, that returns the number of elements in the array (e.g. (4,6) if we have a 2 dimensional array of size 4 by 6). Part A Implement the subclass onebimension for one-dimensional arrays. It must have one data member: a pointer to an array of integers Besides implementing the methods typel) and size() defined in the base class, you have to write code for the following functions a- A constructor that takes zero or one parameter (i.e. the length of the array The default size may be set to 5) b- A destructor that simply deletes the array C-number0Elements(): returns the number of elements stored so far in the array d- Insert): method to add an element into the array in case it is not full e- Search0): method to search for an element and returns the position of that element in case it was found f- Max): returns the maximum value in the arrayExplanation / Answer
//OneDimension class
//Matrices class
//testing
Output:
Type = 1-dimensional
Size = 5
Number of Elements = 0
Calling insert method
Number of Elements = 1
Enter matrix element value...
1
Enter matrix element value...
2
Enter matrix element value...
3
Enter matrix element value...
4
Enter matrix element value...
5
Enter matrix element value...
6
Enter matrix element value...
7
Enter matrix element value...
8
Enter matrix element value...
9
Type = 2-Dimensional
Size = 3
Print =
1 2 3
4 5 6
7 8 9
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.