Website Summary Files Commits Branches @commit @diff @stats
path: root / Week10 / Exercise03 / Inventory.h
blob: 7f5eeca8293e801fe0395259addc5bbbd091e325 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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 */