Question: C + + please #pragma once #include #include #include #include namespace ds { class BigInt { public: BigInt ( ) = default; explicit BigInt (
C please
#pragma once
#include
#include
#include
#include
namespace ds
class BigInt
public:
BigInt default;
explicit BigIntstd::string str;
Since we are not managing dynamic memory, we don't need the rule of three!
void output std::cout this std::endl;
BONUS: TODO: Implement the operator
BigInt operatorconst BigInt& other const
BigInt result;
BigInt::addthis other, result;
return result;
BigInt operatorconst BigInt& other const
BigInt result;
if this other
BigInt::subtractthis other, result;
else
BigInt::subtractotherthis result;
return result;
While this function strictly isn't required, it is helpful for operator
bool operatorconst BigInt& other const;
This operator is used in testing implementing output
friend std::ostream& operatorstd::ostream& os const BigInt& d
TODO: Implement this
private:
Add and Subtract are private as they are internal implementation details
void addconst BigInt& a const BigInt& b BigInt& result const;
void subtractconst BigInt& a const BigInt& b BigInt& result const;
std::vector digits;
;
ds::BigInt::BigIntstd::string str
TODO: Implement this
HINT: Can you use std::transform?
void ds::BigInt::addconst BigInt& a const BigInt& b BigInt& result const
TODO: Implement this
@brief Subtract two BigInts
@param a the first BigInt
@param b the second BigInt
@param result the result of the subtraction
@pre a b
void ds::BigInt::subtractconst BigInt& a const BigInt& b BigInt& result const
TODO: Implement this
Needed to implement absolute difference
bool ds::BigInt::operatorconst BigInt& other const
TODO: Implement this
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
