From 7546f0d0da487e16f0a8671c09a46e1cee2bc03a Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 2 May 2026 14:57:36 +0300 Subject: feat(Week10): Add solutions --- Week10/Exercise03/Inventory.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Week10/Exercise03/Inventory.h (limited to 'Week10/Exercise03/Inventory.h') diff --git a/Week10/Exercise03/Inventory.h b/Week10/Exercise03/Inventory.h new file mode 100644 index 0000000..7f5eeca --- /dev/null +++ b/Week10/Exercise03/Inventory.h @@ -0,0 +1,36 @@ +#ifndef _INVENTORY +#define _INVENTORY + +const unsigned PRODUCT_NAME_LENGTH = 1024; + +struct Product { + char name[PRODUCT_NAME_LENGTH]; + unsigned quantity; +}; + +class Inventory { +protected: + Product* products; + unsigned productsCount; + unsigned productsAlloc; + +private: + void free(); + void copyFrom(const Inventory& other); + + void resize(); + +public: + Inventory(); + ~Inventory(); + Inventory(const Inventory& other); + Inventory& operator=(const Inventory& other); + + Inventory(Inventory&& other); + Inventory& operator=(Inventory&& other); + +protected: + void AddProduct(const Product& product); +}; + +#endif /* _INVENTORY */ -- cgit v1.3.1-24-gd84d