0

Programming test review c++ LAST QUESTION

This problem is giving me a lot of trouble. Can somone please help me? It would be a great help. A machine with 32-bit integers can represent integers in the range of approximately -2 billion to +2 billion. This fixed-size restriction is rarely troublesome, but there are applications in which we would like to be able to use a much wider range of integers. This is what C++ was built to do, namely, create powerful new data types. Given the following class definition, provide the implementation for the friend function and all member functions for the class HugeInt. class HugeInt { friend ostream & operator<< (ostream &, const HugeInt &); public: HugeInt(long value=0) // conversion / default constructor { long temp = value; int count = 0; // determining how many digits are in the number while(temp > 0) { count ++; temp /= 10; } digits = count; // allocate the array and initialize array to zero integers = new short[digits] (0); // place digits of argument into array for (int j = 0; value != 0 && j < digits; j++) { integer[j] = value % 10; value /= 10; } } HugeInt (const HugeInt & ); // copy constructor ~HugeInt(); // destructor //assignment operator HugeInt operator= (const HugeInt &); // addition operator; HugeInt + HugeInt HugeInt operator+ (const HugeInt & ) const; // addition operator; HugeInt + int HugeInt operator+ (int) const; // equality operator; HugeInt == HugeInt bool operator== (const HugeInt &); private: short * integer; int digits; };

31st Mar 2017, 2:34 AM
Adiel Cowo
Adiel Cowo - avatar
1 Respuesta
0
I didn't understand bro sorry.
8th Jun 2020, 6:25 AM
Naveed
Naveed - avatar