the first function works i can enter information, but when I call the second function it's supposed to display the information from the first function...do I 'by reference'? where do I put the & and even the other & or *. I am just learning this c++ and I missed some lectures at the beginning of this semester because I was in the hospital...so help and be kind...lol
Code:#include "stdafx.h" #include <iostream> #using <mscorlib.dll> using namespace std; struct point { public: float quantity; float price; }; void get_input(char, int&, float&); float calculate(char, int, float); int main() { int numbinput, quantity;//, calculate; float price, total; char product; do { cout << endl << "Enter a number: " << endl; cout << "1. Enter Information" << endl; cout << "2. Calculate Sales" << endl; cout << "3. Update Informaton" << endl; cout << "4. Exit" << endl <<endl; cin >> numbinput; switch (numbinput) { case 1: { get_input(product, quantity, price); break; } case 2: { total = calculate(product, quantity, price); break; } } } while (numbinput != 4); return 0; } void get_input(char& product, int& quantity, float& price) { //char product; //int quantity; cout << "Product Name: "; cin >> product; cout << "Quantity: "; cin >> quantity; cout << "Price: "; cin >> price; //cout << "Press the spacebar to continue..."; //getch(); } float calculate (char& product, int& quantity, float& price) { //char prod; //int quant; float total; cout << "Product: " << product; cout << "Quantity: " << quantity; cout << "Price: " << price; total = price * quantity; return total; }



LinkBack URL
About LinkBacks


