error C2660: function does not take 0 arguments

declare function prototype : myLib.h
define function : myLib.cpp
void f(const int a=5) { cout << a * 2 << "\n";}

funtion f works with arguments f(a) , f(2), but not without f()
cpp(13): error C2660: 'f': function does not take 0 arguments ( Visual C++)

if I define function before main is working and f()

[/code]
#include "stdafx.h"
#include <iostream>
#include "myLib.h"
using namespace std;

int a = 123 ;

int main()
{ f(a);
f(2);
f();
return 0;
}
[/code]

Thanks !
The default parameter should be declared in the function prototype (the declaration), not in the implementation (the definition).
Thanks !
Topic archived. No new replies allowed.