#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <cassert>
#include <iterator>
#include <algorithm>

using namespace std;

class LargeInteger {
private:
    static int nextLargeIntegerId;
    int id;
    string digits; // the digits of the LargeInt we are representing

public:
    LargeInteger(int value);
    ~LargeInteger();
    string tostring();
};

LargeInteger::LargeInteger(int value)
{
    // set this instance id
    id = nextLargeIntegerId++;

    // iterate through the digits in value, putting them into our
    // array of digits.
    unsigned char digit;
    while(value) {
        // least significant digit
        digit = value % 10;
        digits += digit;

        // integer division to chop of least significant digit
        value = value / 10;
    }
}

LargeInteger::~LargeInteger()
{
    cout << " destructor entered, freeing my digits" << endl
         << " id = " << id << endl
         //<< " value=" << tostring() // uncomment this after you implement tostring()
         << endl;
}

string LargeInteger::tostring()
{
    string intValue(digits.size(),' ');

    transform (digits.rbegin(), digits.rend(), intValue.begin(), [](auto &x){return x+'0'; }) ; 
    return intValue;
}
int LargeInteger::nextLargeIntegerId = 0; 

int main() {
    // test constructors, destructors and tostring()
    cout << "Testing Constructors, tostring() and destructor:" << endl;
    cout << "-------------------------------------------------------------" << endl;
    LargeInteger li1(3483);
    cout << "li1 = " << li1.tostring() << endl;

    return 0;
}