How can I access a list in C++ by de-referencing the List pointer?
I get bad_alloc error when doing:
List My_List = *ls;
ls is a List*. before in code, I had:
List* ls = & Temp_List;
I used the value of ls as an integer. I passed it through different functions. Now that I want to cast it back to List* and de-reference it, I get the error
If you allocate the list on stack, its address might get changed. But if you allocate it on heap, you won’t lose the pointer to the list (new or malloc)