diff --git a/src/08_PTRN/Testat/BankAccount.cpp b/src/08_PTRN/Testat/BankAccount.cpp index bb970d7..d37fd23 100644 --- a/src/08_PTRN/Testat/BankAccount.cpp +++ b/src/08_PTRN/Testat/BankAccount.cpp @@ -8,6 +8,7 @@ this->owner = owner; BankAccount * BankAccount::operator+(Money * money) { BankAccount::money = new Money(money->getValue() + getMoney().getValue()); + return this; } diff --git a/src/08_PTRN/Testat/main.cpp b/src/08_PTRN/Testat/main.cpp index 6438d40..d00905a 100644 --- a/src/08_PTRN/Testat/main.cpp +++ b/src/08_PTRN/Testat/main.cpp @@ -94,7 +94,8 @@ int main(int argc, char **argv) { *bankAccount + coin; } - Money * fee = * bankAccount - 10; + Money * fee = *bankAccount - 10; + delete fee; } std::cout << *bankAccount << std::endl; } diff --git a/src/10_PITF/Testat/Bill.cpp b/src/10_PITF/Testat/Bill.cpp index 5bf83a9..49a5d3e 100644 --- a/src/10_PITF/Testat/Bill.cpp +++ b/src/10_PITF/Testat/Bill.cpp @@ -4,7 +4,7 @@ using namespace banking; -Bill::Bill(int value, Currency currency, std::string serial) : Cash(value, currency), serial(std::move(serial)){ +Bill::Bill(int value, Currency currency, std::string &serial) : Cash(value, currency), serial(std::move(serial)){ } diff --git a/src/10_PITF/Testat/Bill.h b/src/10_PITF/Testat/Bill.h index f3e82c5..35be3d5 100644 --- a/src/10_PITF/Testat/Bill.h +++ b/src/10_PITF/Testat/Bill.h @@ -18,7 +18,7 @@ namespace banking { private: std::string serial; public: - explicit Bill(int value, Currency currency, std::string serial); + explicit Bill(int value, Currency currency, std::string &serial); explicit Bill(Bill *bill); std::string getSerial(); int getValue() override; diff --git a/src/10_PITF/Testat/HeapObject.cpp b/src/10_PITF/Testat/HeapObject.cpp index 625b16f..07d8fd5 100644 --- a/src/10_PITF/Testat/HeapObject.cpp +++ b/src/10_PITF/Testat/HeapObject.cpp @@ -22,8 +22,6 @@ HeapObject::~HeapObject(){ bool HeapObject::assertionsHold() { //assert(ctorCount == newCount); // all objects have been allocated on heap - std::cout << std::endl; - std::cout << ctorCount << " " << dtorCount << std::endl; assert(ctorCount == dtorCount); // all objects have been deleted return true; } \ No newline at end of file diff --git a/src/10_PITF/Testat/main.cpp b/src/10_PITF/Testat/main.cpp index 4935978..fb71e3c 100644 --- a/src/10_PITF/Testat/main.cpp +++ b/src/10_PITF/Testat/main.cpp @@ -35,17 +35,17 @@ std::ostream &operator<<(std::ostream &os, Cash cash) { return os; } -std::ostream &operator<<(std::ostream &os, std::shared_ptr money) { +std::ostream &operator<<(std::ostream &os, const std::shared_ptr &money) { os << money->getValue() << " " << money->getCurrency(); return os; } -std::ostream &operator<<(std::ostream &os, std::shared_ptr person) { +std::ostream &operator<<(std::ostream &os, const std::shared_ptr &person) { os << person->getName(); return os; } -std::ostream &operator<<(std::ostream &os, std::shared_ptr bankAccount) { +std::ostream &operator<<(std::ostream &os, const std::shared_ptr &bankAccount) { os << bankAccount->getOwner() << " " << bankAccount->getName() << ": " << bankAccount->getMoney(); return os; }