I've just started going through a beginners book of C++. I have some java experience (but having said that, I've never used default arguments in java to be honest)
So, as mentioned, my issue is with default arguments..
This is the code snippet I'm using:
#include <iostream>
using namespace std;
//add declaration
int add(int a, int b);
int main (void)
{
int number1;
cout << "Enter the first value to be summed: ";
cin >> number1;
cout << "\nThe sum is: " << add(number1) << endl;
}
int add(int a=10, int b=5)
{
return a+b;
}
The response I get from g++ compiler is: "too few arguments to function 'int add(int, int)'
Am I doing this wrong? (I've also tried it with literal arguments)
P.S. I can't seem to get the code snippet to display properly? Has the system changed?