I want to know how do u declare a function with definite arguments. It's said to be good practice to put the function declaration at the beginning , before the main() function and then its definition, but in this case the compiler gives me an error, becase it's like if it doesn't see the formal arguments.
#include <iostream>
using namespace std;
void function(int i=1, char a='A', float val=45.7);
int main()
{
function();
return 0;
}
void function(int i = 1, char a='A', float val=45.7)
{
cout << "i: " << i << endl;
cout << "a: " << a << endl;
cout << "val: " << val << endl;
}
I tried to insert the formal arguments in the declaration, but it doesn't work.