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
€85.35
List Price:  €119.49
You save:  €34.14
£72.83
List Price:  £101.96
You save:  £29.13
CA$136.80
List Price:  CA$191.52
You save:  CA$54.72
A$152.93
List Price:  A$214.12
You save:  A$61.18
S$127.41
List Price:  S$178.38
You save:  S$50.97
HK$784.88
List Price:  HK$1,098.87
You save:  HK$313.98
CHF 80.06
List Price:  CHF 112.08
You save:  CHF 32.02
NOK kr1,006.56
List Price:  NOK kr1,409.23
You save:  NOK kr402.66
DKK kr636.73
List Price:  DKK kr891.45
You save:  DKK kr254.71
NZ$165.01
List Price:  NZ$231.03
You save:  NZ$66.01
د.إ367.21
List Price:  د.إ514.11
You save:  د.إ146.90
৳12,147.23
List Price:  ৳17,006.61
You save:  ৳4,859.37
₹8,569.24
List Price:  ₹11,997.28
You save:  ₹3,428.04
RM422.85
List Price:  RM592.01
You save:  RM169.16
₦154,437.55
List Price:  ₦216,218.75
You save:  ₦61,781.20
₨28,364.66
List Price:  ₨39,711.66
You save:  ₨11,347
฿3,245.48
List Price:  ฿4,543.80
You save:  ฿1,298.32
₺3,975.43
List Price:  ₺5,565.76
You save:  ₺1,590.33
B$555.66
List Price:  B$777.95
You save:  B$222.28
R1,766.91
List Price:  R2,473.74
You save:  R706.83
Лв166.84
List Price:  Лв233.58
You save:  Лв66.74
₩135,565.90
List Price:  ₩189,797.69
You save:  ₩54,231.78
₪339.41
List Price:  ₪475.19
You save:  ₪135.78
₱5,669.93
List Price:  ₱7,938.13
You save:  ₱2,268.20
¥14,419.11
List Price:  ¥20,187.34
You save:  ¥5,768.22
MX$1,885.08
List Price:  MX$2,639.18
You save:  MX$754.10
QR362.23
List Price:  QR507.13
You save:  QR144.90
P1,326.09
List Price:  P1,856.57
You save:  P530.48
KSh12,923.70
List Price:  KSh18,093.70
You save:  KSh5,170
E£4,989.15
List Price:  E£6,985.01
You save:  E£1,995.86
ብር13,638.75
List Price:  ብር19,094.79
You save:  ብር5,456.04
Kz91,186.38
List Price:  Kz127,664.58
You save:  Kz36,478.20
CLP$94,330.18
List Price:  CLP$132,066.03
You save:  CLP$37,735.84
CN¥716.97
List Price:  CN¥1,003.79
You save:  CN¥286.82
RD$5,877.61
List Price:  RD$8,228.89
You save:  RD$2,351.27
DA12,947.21
List Price:  DA18,126.62
You save:  DA5,179.40
FJ$224
List Price:  FJ$313.61
You save:  FJ$89.61
Q763.99
List Price:  Q1,069.62
You save:  Q305.62
GY$20,778.93
List Price:  GY$29,091.33
You save:  GY$8,312.40
ISK kr12,154.78
List Price:  ISK kr17,017.18
You save:  ISK kr4,862.40
DH907.13
List Price:  DH1,270.02
You save:  DH362.89
L1,692.46
List Price:  L2,369.51
You save:  L677.05
ден5,255.07
List Price:  ден7,357.32
You save:  ден2,102.24
MOP$803.07
List Price:  MOP$1,124.33
You save:  MOP$321.26
N$1,771.82
List Price:  N$2,480.62
You save:  N$708.80
C$3,654.75
List Price:  C$5,116.79
You save:  C$1,462.04
रु13,679.24
List Price:  रु19,151.49
You save:  रु5,472.24
S/357.26
List Price:  S/500.18
You save:  S/142.92
K411.70
List Price:  K576.40
You save:  K164.70
SAR375
List Price:  SAR525.02
You save:  SAR150.01
ZK2,329.08
List Price:  ZK3,260.81
You save:  ZK931.72
L432.74
List Price:  L605.86
You save:  L173.11
Kč2,113.79
List Price:  Kč2,959.39
You save:  Kč845.60
Ft34,098.03
List Price:  Ft47,738.61
You save:  Ft13,640.57
SEK kr945.24
List Price:  SEK kr1,323.37
You save:  SEK kr378.13
ARS$118,987.09
List Price:  ARS$166,586.68
You save:  ARS$47,599.59
Bs686.26
List Price:  Bs960.80
You save:  Bs274.53
COP$403,751.57
List Price:  COP$565,268.35
You save:  COP$161,516.78
₡50,225.48
List Price:  ₡70,317.68
You save:  ₡20,092.20
L2,594.55
List Price:  L3,632.47
You save:  L1,037.92
₲792,924.32
List Price:  ₲1,110,125.77
You save:  ₲317,201.44
$U4,021.13
List Price:  $U5,629.74
You save:  $U1,608.61
zł362.39
List Price:  zł507.36
You save:  zł144.97
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.