1
0
Fork 0

Ex3.3: Copiable Dynamical Size Stack

This commit is contained in:
Eric Teunis de Boone 2019-12-12 16:56:16 +01:00
parent fa61fdaf21
commit 2ecd14cf94
4 changed files with 185 additions and 0 deletions

View file

@ -9,6 +9,26 @@ class Stack {
public:
Stack() { init( DELTA ); }
Stack( int in_size ) { init(in_size); }
Stack(const Stack& other) {
// Use init to set all vars naturally
init( other.bufsize ) ;
if ( s == other.s )
{
std::cout << "sAmE" << std::endl;
}
// Then update the count as this is dependant on the copied Stack
count = other.count ;
// Copy elements
for ( int i=0 ; i < bufsize ; i++ ) {
s[i] = other.s[i] ;
}
}
~Stack() {
delete[] s;
}