Skip to content

Commit

Permalink
Реализация на конструктор за копиране за разширяващия се стек
Browse files Browse the repository at this point in the history
  • Loading branch information
triffon committed Mar 20, 2019
1 parent f4b087f commit 728ae4b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions stack/rstack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,11 @@ void ResizingStack::resize() {
a = newa;
capacity = new_capacity;
}

ResizingStack::ResizingStack(ResizingStack const& rs)
: top(rs.top), capacity(rs.capacity) {
// !!! a = rs.a;
a = new int[capacity];
for(int i = 0; i <= top; i++)
a[i] = rs.a[i];
}
3 changes: 3 additions & 0 deletions stack/rstack.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class ResizingStack {
// създаване на празен стек
ResizingStack();

// конструктор за копиране
ResizingStack(ResizingStack const&);

// проверка за празнота на стек
bool empty() const;

Expand Down

0 comments on commit 728ae4b

Please sign in to comment.