Question: #ifndef HW2_BIGUINT_H #define HW2_BIGUINT_H #include using namespace std; class BigUInt { private: // Pointer to array. Each element of array contains a digit. // Array

#ifndef HW2_BIGUINT_H

#define HW2_BIGUINT_H

#include

using namespace std;

class BigUInt {

private:

// Pointer to array. Each element of array contains a digit.

// Array length is equal to the number of digits of the BigUInt.

// data[0] contains the least significant digit.

// For example, if the BigUInt represents the number 385,

// then data[0] is 5, data[1] is 8, data[2] is 3, and length is 3.

unsigned char* data;

// The length of the array data.

int length;

public:

// 1. (1 point) Initializes the BigUInt to 0.

BigUInt();

// 2. (5 points) Initializes the BigUInt to n.

// Allocate data to an array the number of digits.

BigUInt(unsigned int n);

// 3. (1 point) Frees space in data.

~BigUInt();

// 4. (1 point) Print the number represented by this BigUInt.

void Print();

// 5. (4 points) Set this BigUInt to original value times 10^p.

// Allocate space as neccessary.

void TimesTenPow(unsigned int p);

// 6. (6 points) Set this BigUInt to original value plus rhs.

// Allocate space as necessary.

BigUInt& operator+=(const BigUInt& rhs);

// 7. (2 points) Print the number represented by this BigUInt.

friend ostream& operator<<(ostream&os, const BigUInt& b);

};

ostream& operator<<(ostream&os, const BigUInt& b);

#endif // HW2_BIGUINT_H

ZOOM

#include

#include "hw2.biguint.h"

using namespace std;

int main() {

BigUInt b1(88408721);

BigUInt b2(69606478);

b1.Print();

b1 += b2;

b1.Print();

b1.TimesTenPow(15);

b1.Print();

b1 += b2;

b1.Print();

cout << b1;

return 0;

}

/*

Results:

88408721

1571015199

1571015199000000000000000

1571015199000000069606478

1571015199000000069606478

*/

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!