1
0
Fork 0
This repository has been archived on 2021-11-03. You can view files and clone it, but cannot push or open issues or pull requests.
uni-m.cds-adv-prog/ex7.4/main.cpp

52 lines
957 B
C++
Raw Normal View History

2020-01-06 15:20:05 +01:00
#include <iostream>
#include "Stack.hh"
using namespace std ;
int main() {
Stack<double> s ;// initialize Stack
// 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 ;
}