-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDefaultArgInFun.cpp
33 lines (27 loc) · 1010 Bytes
/
DefaultArgInFun.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
* project : https://github.com/Robin005cr/Professional_CPP
* file name : DefaultArgInFun.cpp
* author : Robin CR
* mail id : [email protected]
* LinkedIn : https://www.linkedin.com/in/robin-cr/
* portfolio : https://robin005cr.github.io/
*
* Note : If any mistakes, errors, or inconsistencies are found in the code, please feel free to mail me.
* Suggestions for improvements or better methods are always welcome and appreciated.
* I value constructive feedback and aim to continuously improve the quality of the work.
*
*/
#include <iostream>
// Function with default arguments
void display(int x = 10, int y = 20) {
std::cout << "x: " << x << ", y: " << y << std::endl;
}
int main() {
// Calling function with no arguments, default values are used
display();
// Calling function with one argument, the second argument uses the default
display(30);
// Calling function with both arguments, default values are overridden
display(40, 50);
return 0;
}