Original Post
So, I''m reading about default argument values and both books I have show specifying the default values in the function prototypes but NOT in the actual function definition, as in:
#include <iostream>
using namespace std;
void printNumber(int num = 0);
int main()
{
printNumber();
return 0;
}
void printNumber(int num)
{
cout << num;
}
But it seems to me that to be clear, you''d want to use the default values in the definition too, as in:
#include <iostream>
using namespace std;
void printNumber(int num = 0);
int main()
{
printNumber();
return 0;
}
void printNumber(int num = 0)
{
cout << num;
}
I''ve tested both with Dev-C++ (version 4) and both programs work. But is the second version wrong? Why doesn''t any book say you can specify the default values in both the prototypes and definitions of the function? Is this not allowed in Standard C++?