Ex3.3: Copiable Dynamical Size Stack
This commit is contained in:
parent
fa61fdaf21
commit
2ecd14cf94
4 changed files with 185 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Reference in a new issue