Function Parameter Default Values

3 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$99.99
List Price:  $139.99
You save:  $40
€87.14
List Price:  €122
You save:  €34.86
£75.29
List Price:  £105.41
You save:  £30.12
CA$137.33
List Price:  CA$192.27
You save:  CA$54.93
A$141.80
List Price:  A$198.53
You save:  A$56.72
S$128.26
List Price:  S$179.57
You save:  S$51.31
HK$783.27
List Price:  HK$1,096.61
You save:  HK$313.34
CHF 79.54
List Price:  CHF 111.36
You save:  CHF 31.82
NOK kr958.19
List Price:  NOK kr1,341.51
You save:  NOK kr383.31
DKK kr651.09
List Price:  DKK kr911.55
You save:  DKK kr260.46
NZ$171.92
List Price:  NZ$240.70
You save:  NZ$68.77
د.إ367.21
List Price:  د.إ514.11
You save:  د.إ146.90
৳12,287.30
List Price:  ৳17,202.71
You save:  ৳4,915.41
₹9,325.70
List Price:  ₹13,056.36
You save:  ₹3,730.65
RM393.91
List Price:  RM551.49
You save:  RM157.58
₦136,279.37
List Price:  ₦190,796.57
You save:  ₦54,517.20
₨27,955.36
List Price:  ₨39,138.62
You save:  ₨11,183.26
฿3,286.67
List Price:  ฿4,601.47
You save:  ฿1,314.80
₺4,431.56
List Price:  ₺6,204.36
You save:  ₺1,772.80
B$524.65
List Price:  B$734.54
You save:  B$209.88
R1,691.56
List Price:  R2,368.26
You save:  R676.69
Лв170.44
List Price:  Лв238.62
You save:  Лв68.18
₩149,919.27
List Price:  ₩209,892.98
You save:  ₩59,973.70
₪311.64
List Price:  ₪436.31
You save:  ₪124.66
₱6,013.19
List Price:  ₱8,418.71
You save:  ₱2,405.51
¥15,910.69
List Price:  ¥22,275.60
You save:  ¥6,364.91
MX$1,779.28
List Price:  MX$2,491.07
You save:  MX$711.78
QR365.84
List Price:  QR512.19
You save:  QR146.35
P1,364.45
List Price:  P1,910.29
You save:  P545.83
KSh12,958.70
List Price:  KSh18,142.70
You save:  KSh5,184
E£5,222.91
List Price:  E£7,312.29
You save:  E£2,089.37
ብር15,710.10
List Price:  ብር21,994.78
You save:  ብር6,284.67
Kz91,203.97
List Price:  Kz127,689.21
You save:  Kz36,485.24
CLP$91,407.85
List Price:  CLP$127,974.65
You save:  CLP$36,566.80
CN¥689.98
List Price:  CN¥966
You save:  CN¥276.02
RD$6,082.91
List Price:  RD$8,516.33
You save:  RD$2,433.41
DA13,238.41
List Price:  DA18,534.30
You save:  DA5,295.89
FJ$221.85
List Price:  FJ$310.60
You save:  FJ$88.75
Q767.07
List Price:  Q1,073.94
You save:  Q306.86
GY$20,949.93
List Price:  GY$29,330.74
You save:  GY$8,380.81
ISK kr12,478.75
List Price:  ISK kr17,470.75
You save:  ISK kr4,992
DH941.49
List Price:  DH1,318.13
You save:  DH376.63
L1,752.37
List Price:  L2,453.39
You save:  L701.02
ден5,371.73
List Price:  ден7,520.65
You save:  ден2,148.91
MOP$808.41
List Price:  MOP$1,131.81
You save:  MOP$323.39
N$1,679.42
List Price:  N$2,351.26
You save:  N$671.83
C$3,679.63
List Price:  C$5,151.64
You save:  C$1,472
रु14,857.69
List Price:  रु20,801.36
You save:  रु5,943.67
S/343.57
List Price:  S/481.02
You save:  S/137.44
K434.10
List Price:  K607.76
You save:  K173.66
SAR375.47
List Price:  SAR525.67
You save:  SAR150.20
ZK1,958.19
List Price:  ZK2,741.54
You save:  ZK783.35
L444.15
List Price:  L621.83
You save:  L177.68
Kč2,135.46
List Price:  Kč2,989.72
You save:  Kč854.26
Ft34,228.72
List Price:  Ft47,921.58
You save:  Ft13,692.86
SEK kr939.65
List Price:  SEK kr1,315.54
You save:  SEK kr375.89
ARS$139,437.37
List Price:  ARS$195,217.90
You save:  ARS$55,780.52
Bs691.96
List Price:  Bs968.77
You save:  Bs276.81
COP$371,588.45
List Price:  COP$520,238.70
You save:  COP$148,650.24
₡46,992.08
List Price:  ₡65,790.80
You save:  ₡18,798.71
L2,655.43
List Price:  L3,717.71
You save:  L1,062.28
₲647,191.03
List Price:  ₲906,093.33
You save:  ₲258,902.30
$U4,049.61
List Price:  $U5,669.62
You save:  $U1,620
zł372.90
List Price:  zł522.07
You save:  zł149.17
Already have an account? Log In

Transcript

Hello, welcome to the 33rd tutorial in the c++ programming series, and in this part we'll be looking at function parameter default values for values can be provided for functions, and then that particular argument to be emitted. If you do provide default values, only arguments that have default values have to be on the right. We'll show you what we mean in a second. And the reason for this is otherwise the compiler won't know which one when you actually call it. Whenever you specify a value for a variable that actually don't have a default value, or it doesn't, let's just show you what we mean. Let's create a function.

We're gonna say void rain when function In here and passing two numbers in a big, make that equal to five and this is how you default values, you put the equals operator and then you will provide it as simple as that. So if print function is currently passing two numbers, maybe four and five i o before another example, free into a will be free, B will be two. Whereas if you only pass in one parameter, a will be whatever you passed in, and B by default will be five so you can have default value as well. So sore like defaults. I said sorry. So like base values.

So in here, we're simply just going to do STD colon, colon c out. We're going to see a colon B. do best in doing and in line semi-colon. Mr. The operator there, there isn't as simple as corn this function the print function and see as you can see it clearly called one parameter. By default the IntelliSense in Xcode has just detected one parameter free to have by other net to have a necessity. So we're going to put a value of free when according again, get the coin function, and then we'll assign a value for not five one annoying.

Notice when you open up the debug area, so we got free, and it printed out five because we didn't pass in a value for B, but it printed out one and nine for the next print functions. And this is simply because we pass in a value for A and B so the default value more than two, three That's it for this tutorial if you have any questions feel free to message us as well as sonar system coda UK. The email will be in the description comment on this video this direct messages why YouTube, you can also get all recoiling for source code in the description. In the next part we'll be looking at overloaded functions and as usual, thanks for watching and I hope you have a nice day.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.