using shared_ptr

This commit is contained in:
Martin Brodbeck 2018-07-12 13:42:22 +02:00
parent 2c5368c621
commit b69531ced4
2 changed files with 10 additions and 4 deletions

View file

@ -2,9 +2,14 @@
#include <numeric>
void Sale::addArticle(std::shared_ptr<Article> articlePtr)
{
articles_.push_back(articlePtr);
}
int Sale::sumInCents()
{
int test = std::accumulate(articles_.begin(), articles_.end(), 0,
[](int a, Article* b) { return a + b->getPrice(); });
return test;
int sum = std::accumulate(articles_.begin(), articles_.end(), 0,
[](int a, std::shared_ptr<Article> b) { return a + b->getPrice(); });
return sum;
}