using shared_ptr
This commit is contained in:
parent
2c5368c621
commit
b69531ced4
2 changed files with 10 additions and 4 deletions
|
@ -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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue