So, once again, my vague-as-hell book is asking to do something else.
Specifically, this is a direct quote from the book:
"Using default arguments, write a function that asks the user for a number and returns that number. The function should accept a string prompt from the calling code. If the caller doesn't supply a string for the prompt, the function should use a generic prompt. Next, using function overloading, write a function that achieves the same results."
Is it me, or the book? Maybe I'm not cut for programming.
This is my attempt:
Code:#include<iostream>
#include<string>
using namespace std;
int return_number(void);
string return_number(string prompt1 = "Enter in a number: ");
int main()
{
int user_num1 = return_number();
cout << "Thanks for entering: " << user_num1 << ".\n\n";
string user_int1 = return_number("Enter a # man: ");
cout << "Thanks for entering: " << user_int1 << ".\n\n";
return 0;
}
int return_number(void)
{
int user_num;
cout << "Enter a number: ";
cin >> user_num;
return user_num;
}
string return_number(string prompt2)
{
string user_int;
cout << prompt2;
cin >> user_int;
return user_int;
}

