Intarray class

xiaoxiao2021-03-05  25

Implement the class interray accounting to the following class deflaration.

class IntArray {public: // constructorsIntArray (int * array, int array_size); IntArray (const IntArray & rhs); // destructor ~ IntArray () {delete [] ia;} // member functionsbool operator == (const IntArray &) const Bool Operator! = (const INTARRAY &) Const; INTARRAY & OPERATOR = (Const INTARRAY &); int size () const; void sort (); int min () const; int max () const; int find (int value) const; INTARRAY & COPY (INTARRAY & RHS) private: int _size; int * ia;};

============================================================================================================================================================================================================= =======================================================================================================================================================

#include using namespace std; class IntArray {public: IntArray (int * array, int array_size); IntArray (const IntArray & rhs); ~ IntArray () {delete [] ia;} bool operator == (const IntArray &) Const; Bool Operator! = (Const INTARRAY &) Const; INTARRAY & OPERATOR = (const INTARRAY &); int size () const; void sort (); int min () const; int max () const; int found (int value) Const Intarray & Copy; Void show (); private: int _size; int * i;}; INTARRAY :: INTARRAY (INT * Array, int Array_size) {= new int [array_size]; for (int i = 0; I

) IF (IA [i]> IA [j]) TEMP = IA [i], IA [i] = IA [J], IA [J] = Temp;} int tentaar :: min () const {int Temp = IA [0]; for (INT i = 1; i <_size; i ) IF (Temp> IA [i]) TEMP = IA [i]; return temp;} int idaar: max () const {int Temp = IA [0]; for (int i = 1; i <_Size; i ) IF (Temp

Cout << "This time the array size is" << INT1.SIZE () << endl; // Test Size ()

Cout << "The minimum is:" << int1.min () << endl; cout << "maximum is:" << INT1.MAX () << endl; // Test max () MIN ()

IF (INT1 == INT2) cout << "At this time," "ELSE COUT <<" At this time, the two do not wait "<< Endl; // Test ==

INT1.SORT (); // Sort INT1.SHOW (); // Display Test

IF (INT1! = INT2) cout << "At this time," "Else Cout <<" At this time, "" Endl; // Test! = cout << "At this time INT2 : / n "; int2.show (); int2 = int1; cout <<" After assignment: / n "; int2.show (); Intarray Int3 (b, 6); int3.show (); int2.copy (INT3); // Test Copy Int2.show (); INT1.SHOW (); cout << INT1.Find (TEMP) << Endl; cout << INT1.FIND (TEMP1) << Endl; // Test Find () System ("pause"); return 0;}

转载请注明原文地址:https://www.9cbs.com/read-35625.html

New Post(0)