⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testprogderivedlinkedstack.cpp

📁 data+structures+using+c的源码
💻 CPP
字号:
//This program tests various operation of a linked stack

#include <iostream>
#include "derivedLinkedStack.h"

using namespace std;

void testCopy(linkedStackType<int> OStack);

int main()
{
	linkedStackType<int> stack;
	linkedStackType<int> otherStack;
	linkedStackType<int> newStack;
	int num;

	stack.push(34);
	stack.push(43);
	stack.push(27);

	newStack = stack;

	cout<<"After the assignment operator, newStack: "<<endl; 

	while(!newStack.isEmptyStack())
	{
		  num = newStack.top();
 	      newStack.pop();
		  cout<<num<<endl;
	}

	otherStack = stack;

	cout<<"Testing the copy constructor"<<endl;

	testCopy(otherStack);

	cout<<"After the copy constructor, otherStack: "<<endl;

	while(!otherStack.isEmptyStack())
	{
		  num = otherStack.top(); 
 		  otherStack.pop();
		  cout<<num<<endl;
	}

	return 0;
}

void testCopy(linkedStackType<int> OStack) //function to test the 
							 //copy constructor
{
	int num;

	cout<<"Stack in the function testCopy:"<<endl;

	while(!OStack.isEmptyStack())
	{
		  num = OStack.top();
          OStack.pop();
		  cout<<num<<endl;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -