error not happen in first code when i define secound variable with default value but first variable not
#include <iostream>
using namespace std;
#include<cmath>
int ahmed(int x, int y = 7);
int main()
{
ahmed(1, 6);
return 0;
}
int ahmed(int x, int y)
{
cout << x << endl;
cout << y;
}
error happen in secound code when i define firsr variable with default value but secound variable not
#include <iostream>
using namespace std;
#include<cmath>
int ahmed(int x = 7, int y);
int main()
{
ahmed(1, 6);
return 0;
}
int ahmed(int x, int y)
{
cout << x << endl;
cout << y;
}
The second code is supposed to be correct, so why does the error occur?
#include <iostream>
using namespace std;
#include<cmath>
int ahmed(int x = 2, int y = 7);
int main()
{
ahmed(1, 6);
return 0;
}
int ahmed(int x = 2, int y = 7)
{
cout << x << endl;
cout << y;
}
in this case third code why error occurs