- The default parameters of the function must be defined from right to left, that is, there can be no default formal parameters to the right of the model formal parameters For example: int fun (int a = 0, int b, int c = 0)
#include<iostream> //using namespace std; int distance(int x1,int y1,int x2=3,int y2=4); int main() { int a = distance(3,4); int b = distance(4,3); int c = distance(3,4,5); int d = distance(3,4,5,6); std::cout<< a <<std::endl; std::cout<< b <<std::endl; std::cout<< c <<std::endl; std::cout<< d <<std::endl; // cout<< c <<endl; // cout<< d <<endl; return 0; } int distance(int x1,int y1,int x2,int y2) { int x,y; x=x2+x1; y=y2+y1; return x*x+y*y; }