Coursework for the Master's course Computational Data Science: Advanced Programming
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 

52 lines
972 B

#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 ;
}