Closed faheel closed 6 years ago
This error is caused because "12345678901234567890"
is treated as a C string, which is of type const char *
, which being a pointer (integer) is matched with the signature const long long&
, but such a conversion is not allowed, hence the error.
The fix is simple: use the ""s operator to form a string literal from the C string. In other words, add an s
after the string's closing quote:
BigInt num = "12345678901234567890"s;
One caveat though is that this only works in the std
namespace. For a more general fix, you may use one of the following workarounds.
BigInt num = BigInt("12345678901234567890");
BigInt num;
num = "12345678901234567890";
The following doesn't seem to work:
Generates the following error (using g++ version 7.x):