switch statements calling a function
Hello I am new to c++ so please take it easy on me. What I am trying to do is nothing awesome, only call a function that multiplies 2 numbers and outputs a third. This function is called ....aaah I'm sure you know.... here is the code..I get the error
switch.cpp:4: error: too few arguments to function `int doit(int, int, int)'
switch.cpp:29: error: at this point in file
I thought I had enough arguments, I actually thought functions do not even need arguments, that they would just be declared void?
=========================================================
#include <iostream>
using namespace std;
int doit(int x, int y,int z) ////declaring my function doit
{ cout << "Give me a number\n"; ////asking for an int
cin >> x;
cout << "Give me another number\n"; //// asking for the second
cin >> y;
z= x*y; ////setting z to the return value
return (z); //// will this return z for the
//// function?
}
int main()
{
int a; //// the case switch constant
cout << "What would you like to do?\n";
cout << "1:Multiply two numbers\n";
cout << "2:Nothing?\n";
cin >> a; ////case value
switch (a)
{
case 1:
int doit(int x, int y, int z); ////call to doit()
break;
case 2:
cout << "Cya\n";
break;
}
int b= doit(); ////I think this is where I messed
cout <<"\n"<<b<<"\n"; ///it up
return 0;
=======================================================
thanks in advance.......flame away
Last edited by tekmorph; 10-19-2004 at 12:22 PM.
|