c++ - how to assign an int to char* with operator overload -
this question has answer here:
- overloading operator=() callback 1 answer
i have class saves big numbers string , can general mathematical operations on it. 1 of these operations assigning int (0-9) 1 digit of big number. question how can overload operators , convert int
value char*
, save instead of digit in string. following code should work:
\\ bignumber[3] == '8' bignumber[3] = 4 \\ bignumber[3] == '4'
you can convert string
int number; std::ostringstream stream_string; stream_string << number; string numberstring = stream_string.str();
if want convert string char*
bignumber[0] = numberstring.c_str();
Comments
Post a Comment