r/CPPtogether • u/trooflaw • Feb 11 '20
Assignment 2
Write a program that asks the user to input an employees name, then separately, hours worked. The program should multiply the hours worked by a pay rate of $18.50. The user would like the program to return the name and hours entered, the pay rate, and the total net pay for the employee, on separate lines. Ultimately, the program should output:
Employee name: (nameInput)
Hours worked: (hoursInput)
Pay rate: 18.50
Net pay: (product of hoursInput and pay rate)
3
Upvotes
View all comments
Show parent comment
1
u/flappyprince Feb 12 '20
For local variables they are essentially the same, but brace initialization has better performance on some other data types, so it's favorable for consistency reasons. Another advantage over copy initialization, is that you'll get an error if you try to initialize a value which the type cannot hold. For example: