/* * exo2.cpp * * Created on: Oct 3, 2016 * Author: sam */ #include #include using namespace std; struct Enreg { int stock; double price; vector sales; }; void reset(Enreg *enregStruct){ enregStruct->stock = 0; enregStruct->sales.clear(); } void display(Enreg *enregStruct){ cout << "Stock: " << enregStruct->stock << endl; cout << "Price: " << enregStruct->price << endl; cout << "Sales: "; vector::iterator pos; for(pos = enregStruct->sales.begin(); pos != enregStruct->sales.end(); pos++){ cout << *pos << " "; } cout << endl; } void display(Enreg *enregStruct, int month){ cout << "Sales["<< month <<"]: "; cout << enregStruct->sales.at(month) << endl;; } int main () { vector mystock_sales(12,4); Enreg mystock = {200, 12, mystock_sales}; display(&mystock); display(&mystock, 3); reset(&mystock); display(&mystock); }