xersi xersi - 2 months ago 6
C++ Question

Assign a BigInteger to a normal integer

For example, I can do this :

uint64_t a = 100;
BigInteger b = a;


But I can't do this :

BigInteger a = 100;
uint64_t b = a;


Is there any way? Thanks.

Answer

The simplest solution is to make BigInteger implicitly convertible to uint64_t. This can be achieved with a conversion operator:

BigInteger::operator uint64_t();
Comments