I am doing a BigInt implementation and for one of my constructors, I'm required to take in an int value and basically convert it to a string, and then take each character and save it into a node of a linked list.
My struct Digit Node is a doubly linked list with value 'char digit'. My class BigInt has two private member variables head and tail. (which are pointers to DigitNode).
I am getting this error: error: call of overloaded ‘to_string(int&)’ is ambiguous
My file headers:
#include <iosfwd> #include <iostream> #include "bigint.h" using namespace std; My constructor:
BigInt::BigInt(int i) // new value equals value of int (also a default ctor) { string num = to_string(i); DigitNode *ptr = new DigitNode; DigitNode *temp; ptr->prev = NULL; this->head = ptr; if (num[0] == '-' || num[0] == '+') ptr->digit = num[0]; else ptr->digit = num[0] - '0'; for (int i = 1; num[i] != '\0'; i++) { ptr->next = new DigitNode; temp = ptr; ptr = ptr->next; ptr->digit = num[i] - '0'; ptr->prev = temp; } ptr->next = NULL; this->tail = ptr; } Thanks for your help!
to_stringor the one included in the standard library?