[ create a new paste ] login | about

Link: http://codepad.org/iUfTnJc7    [ raw code | fork ]

C++, pasted on Oct 13:
#include <iostream>
#include "Stack.h"

using namespace std;

static void Disp(const CStack<int> stack)
{
	cout << "in Disp" << endl;
	cout << "\tStack Top   -) " << stack.Top() << endl;
	cout << "\tStack Size  -) " << stack.Size() << endl;
	cout << "\tStack Bytes -) " << stack.Bytes() << endl;
}

int main()
{
	CStack<int> stack;
	
	stack.Push( 10 );
	stack.Push( 20 );
	stack.Push( 30 );
	stack.Top() -= 5;
	Disp( stack );
	
	cout << "in Main" << endl;
	while (! stack.Empty())
		cout << "\tStack Pop -) " << stack.Pop() << endl;
	stack.Push( 1000 );
	Disp( stack );
	
	cout << "-------------------------------------------" << endl;
	CStack<int> copy;
	
	copy = stack;
	copy.Push( 1001 );
	Disp( copy );
	cout << "in Main" << endl;
	while (! copy.Empty())
		cout << "\tCopy Pop -) " << copy.Pop() << endl;
	
	return 0;
}
/*
Results >

in Disp
        Stack Top   -) 25
        Stack Size  -) 3
        Stack Bytes -) 12
in Main
        Stack Pop -) 25
        Stack Pop -) 20
        Stack Pop -) 10
in Disp
        Stack Top   -) 1000
        Stack Size  -) 1
        Stack Bytes -) 4
-------------------------------------------
in Disp
        Stack Top   -) 1001
        Stack Size  -) 2
        Stack Bytes -) 8
in Main
        Copy Pop -) 1001
        Copy Pop -) 1000

*/


Create a new paste based on this one


Comments: