I'm having severe problems with my code. We are asked to take in the Vehicle name, tank size, and MPG. We are give the distance between the cities and are supposed to output the # of tankfuls required to make the ship. The errors I am getting are:
variable or field 'doOutput' declared vod
'int doOutput' redeclared as different kind of symbol
previous declaration of 'void doOutput
declaration of 'int doOutput'
conflicts with previous declaration 'void doOutput'
Then it tells me that Vehicle, MPG, and fillups are not declared on line 90 (were the function is supposed to be opened)
What is wrong? It seems to revolve around the redelcaration that is happening of doOutput. But why is it doing this?
using namespace std;
cout << "Welcome, please choose one of the following options" << '\n';
cout << '\n';
cout << "1. Enter the data!" << '\n';
cout << "2. Quit the Program!" << '\n';
cout << "Enter the choice you would like below: ";
cin >> choice;
cout << "DO IT AGAIN! I SAID PICK FROM THE CHOICES!!!" << '\n';
ATP BE400 CE500 (C550B-SPW) CE560XL MU300 CFI CFII
"The speed of non working code is irrelevant"... Of course that is just my opinion, I could be wrong.
"Nothing in the world can take the place of persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination are omnipotent. The slogan 'press on' has solved and always will solve the problems of the human race."...Calvin Coolidge 30th President of the USA.
Can we name the local variables of a function with the same names of parameters
we are passing to it ? How the program will work then ?
Please note, the variable name has a scope where it remains effective. If variable is declared as function parameter or local function variable, the scope is going to be limited by function body. Out of this scope the variable of the same name means absolutely different region of memory.
Back to the S_M_A's sample:
int Something(int a) // (2)
int a = 1; // (1)
std::cout << "Something is " << Something(a) << std::endl; // (3)
Variable a (1) is a memory absolutely different from a (2), though the value from a (1) gets copied to a (2) when call occurs in (3).