int pop(node *&stack)
it is a function taking pointer to node by reference (that means it can change that pointer) and returns integer.
node *top=new node;
Memory leak. We are declaring pointer to node, allocating memory for node and assigning pointer to freshly allocated memory to top
http://www.cplusplus.com/doc/tutorial/dynamic/
top=stack;
We are assigning stack pointer to top. Now they both points to the same object
Previous two lines should be:
node* top = stack;
result=top->data;
Accessing data member of node object held in top. and storing it in result variable
http://www.cplusplus.com/doc/tutorial/classes/ (Pointers to classes)
stack=top->link;
Extracting pointer to the next element and assigning stack variable to it, effectively removing top element from stack
node *neww=new stack
mistake, should be
node* neww = new node;
creates node object in memory and assigning its address to neww pointer.
neww->data=exp[i];
storing brace character in data field.
neww->link=stack;
Make link member point to therest of the stack
stack=neww;
And make pointe to the beginning of stack point to the new node.
(Pairs(pop(stack), exp[i])==0)
It takes top value from stack, removing it (
pop(stack)
) and i'th character from string (
exp[i]
) which is one of the closing braces due to previous if; passes them to the Pairs function (which checks if pairs match) and compares result to 0 ("if pairs really match")
I must warn that those C-like stack manipulations have several sources of memory leaks.