52 lines
		
	
	
	
		
			972 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			52 lines
		
	
	
	
		
			972 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| #include <iostream>
 | |
| #include "Stack.hh"
 | |
| 
 | |
| using namespace std ;
 | |
| 
 | |
| int main() {
 | |
| 	Stack<double> s(5) ;// initialize Stack
 | |
| 	s.push(5);
 | |
| 
 | |
| 	// Write doubles into Stack
 | |
| 	int i ;
 | |
| 	for (i=0 ; i<10 ; i++) {
 | |
| 		cout << "pushing value " << i*i << " in stack" << endl ;
 | |
| 
 | |
| 		s.push(i*i) ;
 | |
| 	}
 | |
| 
 | |
| 	cout << "Clone s to sclone" << endl;
 | |
| 	Stack<double> sclone = s;
 | |
| 
 | |
| 	cout << "Inspect s's FIFO" << endl;
 | |
| 	s.inspect();
 | |
| 	
 | |
| 	cout << "Inspect sclone's FIFO" << endl;
 | |
| 	sclone.inspect();
 | |
| 	//The Same Data
 | |
| 
 | |
| 	while (!s.empty()) {
 | |
| 		double val = s.pop() ;
 | |
| 		cout << "popping value " << val << " from stack" << endl ;
 | |
| 	}
 | |
| 
 | |
| 	cout << "Inspect s's FIFO" << endl;
 | |
| 	s.inspect();
 | |
| 	
 | |
| 	cout << "Inspect sclone's FIFO" << endl;
 | |
| 	sclone.inspect();
 | |
| 	//Not the Same Data after copy constructor
 | |
| 
 | |
| 	for (int i = 0; i < 5 ; i++ )
 | |
| 	{
 | |
| 		s.push(100*i) ;
 | |
| 	}
 | |
| 
 | |
| 	cout << "Inspect s's FIFO" << endl;
 | |
| 	s.inspect();
 | |
| 	
 | |
| 	cout << "Inspect sclone's FIFO" << endl;
 | |
| 	sclone.inspect();
 | |
| 	//Not the Same Data after copy constructor
 | |
| 	return 0 ;
 | |
| }
 | 
