#include<iostream>
#include<string>
//#include "banned.h"
//#include<cassert>
using namespace std;
/*2a.*/
class Date
{
int day;
int month;
int year;
public:
Date (int, int, int) : day(1), month(1), year(1970) {}
int getDay() {return day;}
int getMonth() {return month;}
int getYear() {return year;}
};
/*2b. InventoryItem containing Name, Cost, Quantity, DatePurchased(Object of the date Class), InventoryTotal(Static Variable)*/
class InventoryItem
{
string Name;
double Cost;
int Quantity;
static int InventoryTotal;
public:
Date DatePurchased; /*Object of the date class*/
InventoryItem() : Name(" "), Cost(0.0), Quantity(0), DatePurchased(1,1,1970) {}
void setInventoryTotal(int amt) { InventoryTotal = amt; }
string getName() {return Name;}
double getCost() {return Cost;}
int getQuantity() {return Quantity;}
// Date getDatePurchased() { }
int getInventoryTotal() {return InventoryItem::InventoryTotal;}
/*2.c friend function to change quantity of Inventory item*/
friend void changeQuantity(int);
void changeQuantity(int quan) { Quantity = quan; }
};
int main ()
{
/*3. main function that instantiates 10 InventoryItem objects using arrays; should use friend function to change
the quantity of 4 InventoryItem objects*/
InventoryItem testit;
/* changing quantity works
testit.changeQuantity(10.00);
cout << testit.getQuantity();
*/
cout << testit.DatePurchased.getDay(); /* this doesn't */
/* 10 iterations loop */
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPHN0cmluZz4KLy8jaW5jbHVkZSAiYmFubmVkLmgiCi8vI2luY2x1ZGU8Y2Fzc2VydD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCi8qMmEuKi8KY2xhc3MgRGF0ZQp7CglpbnQgZGF5OwoJaW50IG1vbnRoOwoJaW50IHllYXI7CnB1YmxpYzoKCURhdGUgKGludCwgaW50LCBpbnQpIDogZGF5KDEpLCBtb250aCgxKSwgeWVhcigxOTcwKSB7fQoJaW50IGdldERheSgpIHtyZXR1cm4gZGF5O30KCWludCBnZXRNb250aCgpIHtyZXR1cm4gbW9udGg7fQoJaW50IGdldFllYXIoKSB7cmV0dXJuIHllYXI7fQp9OwoKLyoyYi4gSW52ZW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