{
int a[3];
mainClassStack.pushNumber(a[1,2,3]);
break;
}
void stack_class::pushNumber(int numberFunc)
{
if(head==NULL)
{
head = new stack_struct;
head->number = numberFunc;
head->next_number = NULL;
tailPointer=head;
}
else
{
pointerFunc = new stack_struct;
pointerFunc->number=numberFunc;
pointerFunc->next_number=NULL;
head->next_number=pointerFunc;
head=pointerFunc;
}
}
void stack_class::pushNumber(char charFunc)
{
int a=0;
a=charFunc;
if(head==NULL)
{
head = new stack_struct;
head->number = a;
head->next_number = NULL;
tailPointer=head;
}
else
{
pointerFunc = new stack_struct;
pointerFunc->number=a;
pointerFunc->next_number=NULL;
head->next_number=pointerFunc;
head=pointerFunc;
}
}
void stack_class::pushNumber(int arrayFunc[3])
{
if(head==NULL)
{
for(int i=0;i<3;i++)
{
head = new stack_struct;
head->number = arrayFunc[i];
head->next_number = NULL;
tailPointer=head;
}
}
else
{
for(int i=0;i<3;i++)
{
pointerFunc = new stack_struct;
pointerFunc->number=arrayFunc[i];
pointerFunc->next_number=NULL;
head->next_number=pointerFunc;
head=pointerFunc;
}
}
}
I am overloading functions and pushing an array into the appropriate function which will later add the values from the arrays to a dynamic linked list. So far I have written this, but when I try to print the linked list, it shows garbage. What am I doing wrong here?