Skip to content

Commit

Permalink
Пример за хетерогенен контейнер
Browse files Browse the repository at this point in the history
  • Loading branch information
triffon committed May 11, 2022
1 parent 26274be commit 356e567
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lectures/1/player/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,24 @@ void testSuperHero() {
std::cout << "Изтрихме hero!\n";
}

void testPlayers() {
Player* players[] = { new Player("Катнис Евърдийн", 1),
new Hero("Гандалф", 45, 10),
new SuperHero("Супермен", 100, 5, "летене", false, 10),
new SuperHero("Dr. Strange", 20, 8, "отваряне на портали", true, 9)
};
size_t playerCount = sizeof(players) / sizeof(players[0]);
for(int i = 0; i < playerCount; i++)
players[i]->println();
for(int i = 0; i < playerCount; i++)
delete players[i];
}

int main() {
// testCopyPlayer();
// testArrayPlayer();
// testHero();
testSuperHero();
// testSuperHero();
testPlayers();
}

0 comments on commit 356e567

Please sign in to comment.