0

strings in functions

Is it possible to create a function that uses strings? the examples here are only numbers

16th Jan 2017, 12:21 PM
Venon Thabo Mngometulu
Venon Thabo Mngometulu - avatar
1 ответ
+ 1
#include <iostream.h> #define Shorti "option 1" // I've defined Shorti, #define Junior "option 2" // Junior, #define King "option 3" // and King as option 1, 2 and 3 using namespace std; // You forgot to use the std namespace double options(string option1, string option2, string option3) // Declare options all in one line, and put it above the main function { cout << "1." << option1 << endl; cout << "2." << option2 << endl; cout << "3." << option3 << endl; } int main() { using namespace std; double order; cout << "Wawa Order" << endl; cout << "Hoagie Size? "; options(Shorti, Junior, King); cin >> order; /*********************************** ** Here's the extra bit for the menu choice** ***********************************/ switch(order) { case 1: { // Do stuff for 1 } case 2: { // Do stuff for 2 } case 3: { // Do stuff for 3 } } return 0; } // You forgot to end the main function
16th Jan 2017, 12:48 PM
NiKlAuS
NiKlAuS - avatar