I have a constructor that creates a linked list from an input string. Each digit of the input string goes in its own node in the list. The constructor works fine, in that at the end of the constructor, I can iterate through the list and output the string.
However, I need to create a pointer to the first (and last) nodes in the newly created list, which I can also do. But when I get back to int main(), I can't get the pointer to function properly. I can prove (by cout) that my pointer has been created and the address stored in the pointer is the same at the end of the constructor as it is back in main(). But when I output the data stored in the node that the pointer points to, that data has changed.
Here' the relevant code:
1 2 3 4 5 6 7 8 9 10 11
int main ()
{
string test_string = "987";
Big_Int bi_1("987"); //tested
//this outputs the same address that I see at the end of the contructor
cout << "bi_1 digit ptr: " << bi_1.get_first_digit_ptr() << endl;
//but this outputs something that I don't recognize (it should output a 9
cout << "bi_1 digit: " << bi_1.get_first_digit_ptr()->data() << endl;
}