Exercise 2.9
#include<iostream>
int main()
{
int input_value;
std::cin >> input_value;
int i = {
3 };
double salary, wage;
salary = wage = 9999.99;
int j = 3.14;
}
a: Illegal variables defined in the input
b: List initialization will re-initialize the value when there is a risk of losing information
c:wage is the assignment is not defined
d: correct, but the data will be lost
Exercise 2.10
#include<iostream>
std::string global_str;
int global_int;
int main()
{
int local_int;
std::string local_str;
}
global_str: empty string
global_int: 0
local_int: uninitialized, undefined value (built-in type in the function)
local_str: empty string