Can someone explain to me why, in the Push_Back function, the values of a structure are erased?
class Lista2
{
public:
typedef struct Element
{
Element(int newValue)
{
value = newValue;
next = nullptr;
}
Element* next;
int value;
Element* prev;
};
Element* first;
void init() {
Element ok(0);
first = &ok;
}
void Push_Back(int value)
{
Element* temp = first;
Element* temp2;
temp2 = new Element(value);
if (temp != nullptr)
{
while (temp->next != nullptr)
{
temp = temp->next;
}
temp->next = temp2;
}
else first = temp2;
}
I called the function: init() and after Push_Back(). In Push_back I see this in debuger:
Can someone explain to me why, in the Push_Back function, the values of a structure are erased?