if i try to use this constructor
BigNum d("-2345");
how do i get the compiler to convert the string to a negative number?here's the code i have for this constructor
BigNum::BigNum(string s)
{
num = new node;
num -> next = NULL;
num -> val = 0;
int i, j, r;
i = s.size();
i--;
r = 1;
node * curr;
curr = num;
sign = "+";
while (i >= 0)
{
j = s[i] - 48;
if (r == 1)
curr -> val = j;
if (r == 2)
curr -> val += j*10;
if (r == 3)
{
curr -> val += j*100;
if(i > 0)
{
curr -> next = new node;
curr = curr -> next;
curr -> next = NULL;
}
r = 0;
}
r++;
i--;
}
}
<< moderator edit: added [co[u][/u]de][/co[u][/u]de]
tags >>
all help is greatly appreciated!