[Solved] How to Implement stack by function pointer and how to use it [closed]

No, function members cannot be declared in C structs (only in C++). The convention is to pass the struct pointer as the first argument in the functions when doing object oriented programming. Also, C++ really does the same thing, the “this” pointer is passed as the first argument, it is just hidden. struct stack{ int[10] … Read more

[Solved] Data Structre of Stack in C

When you call CreateStack, the pointer is passed by value. The pointer that is returned by the call to malloc in your function is never assigned to the STACKHEAD. Try writing a CreateStack function that returns a pointer to the stack that gets created. It should not take any arguments. 1 solved Data Structre of … Read more

[Solved] Pop() function for stack in C

It would help to see how you push items onto the stack. If you’re really calling pop without a push first, well, then it’s not supposed to do anything, is it? This bit makes me nervous: Node *aux,*prev; prev = *stack; aux = prev->next; if(aux == NULL) { free(prev); return; } You set prev to … Read more

[Solved] Postfix notation stack C++ [closed]

Using stack.top() is illegal if the stack is empty. Change while((!highPrecedence(stack.top(),c)) && (stack.size()!=0)){ to while((!stack.empty()) && (!highPrecedence(stack.top(),c))){ The initiali value of i is not good and you are printing uninitialized variable, which has indeterminate value. Change int i=0; to int i=-1; 1 solved Postfix notation stack C++ [closed]

[Solved] Why does the difference emerge between this two codes in C: Array Implementation for Stack and Linked List Implementation for Stack?

Why does the difference emerge between this two codes in C: Array Implementation for Stack and Linked List Implementation for Stack? solved Why does the difference emerge between this two codes in C: Array Implementation for Stack and Linked List Implementation for Stack?

[Solved] Problem with pushing into stack with generic type [closed]

Your question misses important details and actually I shouldnt be writing this answer, but as you actually also didnt ask a question, I just do it. This error message: error: no matching function for call to ‘AlgoStack<State<std::pair<int, int>* >>::push(State<std::pair<int, int> >*&)’ tells us that there is an instantiation of AlgoStack with the template parameter being … Read more

[Solved] function to calculate the sum of odd numbers in a given stack [closed]

just an example, you could pass your stack variable as an argument to the GetSum() function. private static int GetSum() { Stack<int> stack = new Stack<int>(); stack.Push(2); stack.Push(5); stack.Push(7); stack.Push(4); stack.Push(1); int sum = 0; foreach (int number in stack) { if (number % 2 != 0) { sum += number; } } return sum; … Read more

[Solved] Stack implementation java

pop() is not working because you are using different objects for push and pop. You don’t need to define another class for push and pop, they are operation add those function inside Stack class. class Stack { … // members and constructor public void push(){..} public void pop(){..} public void show(){..} } And create an … Read more