Skip to content

Commit

Permalink
Унищожаване на динамичен масив от обекти
Browse files Browse the repository at this point in the history
  • Loading branch information
triffon committed Mar 30, 2022
1 parent 3d7297f commit 7661a82
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lectures/1/player/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ void testCopyPlayer() {
createPlayer().print();
}

void testArrayPlayer() {
Player* players = new Player[10];
// !!! delete players;
delete[] players;
}

int main() {
testCopyPlayer();
// testCopyPlayer();
testArrayPlayer();
}
1 change: 1 addition & 0 deletions lectures/1/player/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Player::Player(Player const& other) : name(nullptr), score(other.score) {
}

Player::~Player() {
std::clog << "~Player()\n";
delete[] name;
}

Expand Down

0 comments on commit 7661a82

Please sign in to comment.