Skip to content

Commit

Permalink
try to solve pezy#15
Browse files Browse the repository at this point in the history
  • Loading branch information
pezy committed Feb 6, 2015
1 parent d5255d5 commit cfe5ab0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions ch02/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,12 @@ int month = 9, day = 7;
int month = 09, day = 07;
```

The first line's integer is decimal, the second line's integer is octal.
The first line's integer is decimal.

The second line:

1. `int month = 09` is invalid, cause octal don't have digit `9`.
2. `day` is octal.

##Exercise 2.7
> What values do these literals represent? What type does each
Expand Down Expand Up @@ -158,7 +163,7 @@ int input_value = 0;
std::cin >> input_value;
```

(b):---when you compile the code without the argument "-std=c++11", you will get the warning below:
(b):---when you compile the code without the argument "-std=c++11", you will get the warning below:
warning: implicit conversion from 'double' to 'int' changes value from 3.14 to 3.
---when you compile the code using "-std=c+11", you will get a error below:
error: type 'double' cannot be narrowed to 'int' in initializer list
Expand Down Expand Up @@ -195,7 +200,7 @@ int main()
`global_int` is global variable, so the value is zero.
`local_int` is a local variable which is not uninitialized, so it has a undefined value.
`local_str` is also a local variable which is not uninitialized, but it has a value that is defined by the class. So it is empty string.
PS: please read P44 in the English version, P40 in Chinese version to get more.
PS: please read P44 in the English version, P40 in Chinese version to get more.
The note: Uninitialized objects of built-in type defined inside a function body have a undifined value. Objects of class type that we do not explicitly inititalize have a value that is defined by class.

##Exercise 2.11
Expand Down

0 comments on commit cfe5ab0

Please sign in to comment.