lab10.cpp - This program passes a structure variable to one...

This preview shows page 1 - 2 out of 2 pages.

// This program passes a structure variable to one function // by reference and to another as a constant reference. #include <iostream> #include <iomanip> #include <string> using namespace std; struct InvItem // Holds data for an inventory item { int partNum; // part number string description; // Item description int onHand; // Units on hand double price; // Unit price }; // Function protptypes void getItemData(InvItem &); // Function getItemData will reveive an // InvItem structure passed to it by // reference so new values can be stored // in its memeber variables void showItem(const InvItem &); // Function showItem will receive a // InvItem structure passed to it as a // constant refence because showItem // just needs display member variable // values, not change them. int main() { InvItem part; // Define an InvItem structure variable getItemData(part); showItem(part); system("pause"); return 0; } /******************************************************************** * getitemData * * This function stores data input by the user in the members of an * * Invitem structure variable passed to the function by reference.
Image of page 1

Subscribe to view the full document.

Image of page 2
  • Summer '18
  • Yinping Jaio
  • getline, #include, structure variable

{[ snackBarMessage ]}

Get FREE access by uploading your study materials

Upload your study materials now and get free access to over 25 million documents.

Upload now for FREE access Or pay now for instant access
Christopher Reinemann
"Before using Course Hero my grade was at 78%. By the end of the semester my grade was at 90%. I could not have done it without all the class material I found."
— Christopher R., University of Rhode Island '15, Course Hero Intern

Ask a question for free

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern