// ;----------------------------------------------------------- // ; Program Name: Class_Demo // ; File: Structest.cpp // ; Description: Demonstrates Structures // ; Author: Jim Adams // ; Environment: MS C++ 6.0 // ; Date Written: 07/13/2001 // ;----------------------------------------------------------- #include struct date { int year; int mon; int day; }; struct book { // Structure Template char title[30]; char author[25]; int quantity; float cost; date current_date; } library; // Structure Variable // Prototypes float calculate(float, int); void get_input(float&, int&); int main(void) { get_input(library.cost, library.quantity); cout << calculate(library.cost, library.quantity) << endl; return(0); } // Function to compute inventory cost // Passes two structure variables // Call by value float calculate(float cost, int quan) { return(quan * cost); } // Function to get input variables // Passed structure variables but allows them to be changed // Call by reference void get_input(float& c, int& q) { cout << "Enter Book Quantity:"; cin >> q; cout << "Enter Book Cost:"; cin >> c; }