I'm trying to write a program that gets a really long number So at first I keep it as a string and am supposed to perform simple operators But I do not know how I'm supposed to store such a long number to do these things
Here's what I did, Header:
class BigInteger
{
private:
string number;
public:
BigInteger();
BigInteger(int);
BigInteger(const char*);
BigInteger(const BigInteger&);
BigInteger(const BigInteger&&);
//~BigInteger();
void setValue(int);
void setValue(const char*);
//void setValue(const BigInteger&);
string getnum();
static BigInteger fromString(const char*);
const BigInteger operator+(const BigInteger&) const;
const BigInteger operator-(const BigInteger&) const;
const BigInteger operator*(const BigInteger&) const;
const BigInteger operator/(const BigInteger&) const; }
main:
#include "BigInteger.h"
using namespace std;
int main()
{
BigInteger a("2837456897658923563425345");
BigInteger b("23784623874623874682736478236");
BigInteger c = a + b;
c /= "4237467864237846";
BigInteger d = a * b - c;
}
thats the main and how i would like it to run, In the implementation of the functions, I managed to get all the constractors to work, but i dont know how to build the operators to work because there is no type that can contain that long numbers... what can i do?