plz
how i can write a program to pop from one stack and save the value deleted to onther stack ..

means .. pop the top from one stack and push the delete value to other stack ...


:(

Unless you have the dumbest stack ever written, it should be possible to retrieve the top before popping it (or the pop operation returns the removed top). Take that value and pop it onto the other stack.

Notice though that in case of multiple pops and pushes you have the value order reversed in other stack. You should tell what you plan to do with this program, maybe you are not doing the correct thing.

#include <iostream.h>
 

// global variables declation
struct stack 
{ int  info;
   struct stack *next;
};

class stack1
{ private:
	   stack *Top;
    int item;

public:
	
	stack1 () {Top = NULL;}  // constructor, which automatically executes when object of the class will be created

 


	void Push(int item)
		{
		cout<<"enter number";
		cin>>item;
			  stack *Newnode = new stack;
			Newnode-> info = item;
			Newnode-> next = NULL;
			if(Top == NULL) Top = Newnode;
			else
			{ Newnode -> next = Top; Top = Newnode; }
		}

	int Pop( )
		{  struct stack *t;
	       item = Top - > info;
		   t = Top;
			Top = Top ->next;
			delete t;
			return item;
		}

	bool IsEmpty( )
		{ if(Top == NULL ) return true; else return false; }
		
	void Traverse( )
		{  stack *TopTemp = Top;
			do{ cout<<TopTemp->info<<endl; TopTemp = TopTemp->next;} while(TopTemp!= NULL 0);
		}
}; //  end of the class


  
  
  
int main( )
{ 
	stack1  z;  // Creation of an object
 z.Push();
 z.Pop();
 z.Traverse();
     return 0;
}

i try to pop and push from one stack
but i face errors ..

Don't know about the errors as you did not post error messages, but I think that placing user input inside push is not bright idea, to put it mildly.

I would call your stack stacknode and stack1 class Stack.

Your indention also looks quite "personal".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.