Skip to content

Commit

Permalink
corrected spelling for the first three chapters
Browse files Browse the repository at this point in the history
  • Loading branch information
SimplyDing authored and pezy committed Apr 12, 2015
1 parent 356cbc4 commit bfe4474
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions ch02/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ std::cin >> input_value;
double i = { 3.14 };
```
(c): --if you declared 'wage' before, it's right. Otherwhise, you'll get a error:
(c): --if you declared 'wage' before, it's right. Otherwise, you'll get a error:
error: use of undeclared identifier 'wage'
```cpp
double wage;
Expand Down Expand Up @@ -201,7 +201,7 @@ int main()
`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.
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.
The note: Uninitialized objects of built-in type defined inside a function body have a undefined value. Objects of class type that we do not explicitly inititalize have a value that is defined by class.

##Exercise 2.11
> Explain whether each of the following is a declaration or a
Expand Down Expand Up @@ -274,7 +274,7 @@ Yes.It is legal.Printed:

```
(a): valid. let d equal 3.14159.
(b): valid. automatical convert will happen.
(b): valid. automatic convert will happen.
(c): valid. but value will be truncated.
(d): valid. but value will be truncated.
```
Expand Down Expand Up @@ -309,7 +309,7 @@ p1 = &b;
####definition:

the pointer is "points to" anyother type.
the pointer is "points to" any other type.

the reference is "another name" of an **object**.

Expand All @@ -320,7 +320,7 @@ a pointer is an object in its **own right**.
2. Once initialized, a reference remains **bound to** its initial object.
There is **no way** to rebind a reference to refer to a different object.
a pointer can be **assigned** and **copied**.
3. a reference always get the object to which the reference was intially bound.
3. a reference always get the object to which the reference was initially bound.
a single pointer can point to **several different objects** over its lifetime.
4. a reference must be initialized.
a pointer need **not be** initialized at the time it is defined.
Expand Down Expand Up @@ -369,7 +369,7 @@ if (*p) // whether the value pointed by p is zero?
##Exercise 2.23
>Given a pointer p, can you determine whether p points to a valid object? If so, how? If not, why not?
No. Because more information needed to determine whether the pointee is valid or not.
No. Because more information needed to determine whether the pointer is valid or not.


##Exercise 2.24
Expand Down Expand Up @@ -531,7 +531,7 @@ decltype((b)) d = a;
++d;
```
`c` is an int, `d` is a referance of `a`.
`c` is an int, `d` is a reference of `a`.
all their value are `4`.
##Exercise 2.37
Expand Down
10 changes: 5 additions & 5 deletions ch03/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
##Exercise 3.2 : [part1](ex3_2a.cpp) | [part2](ex3_2b.cpp)
##Exercise 3.3
>Explain how whitespace characters are handled in the string
input operator and in the getline function.
input operator and in the `getline` function.

The `getline` function takes an input stream and a string.
This function reads the given stream up to and including
the first newline and stores what it read—not including
the newline—in its string argument.
After getline sees a newline, even if it is the first character in the input,
After `getline` sees a newline, even if it is the first character in the input,
it stops reading and returns.
If the first character in the input is a newline,
then the resulting string is the empty string.
Expand Down Expand Up @@ -142,7 +142,7 @@ please see 2.2.1. Variable Definitions -> Default Initialization.

`std::string` isn't a build-in type. The initializer will set it empty.
`ia` and `ia2` are build-type. But `ia` isn't in the function body, so it
will be initalized to **zero**. `ia2` is in the function body. so it's
will be initialized to **zero**. `ia2` is in the function body. so it's
value is **undefined**.

You can also use gdb to debug the value when the code is running.
Expand All @@ -151,7 +151,7 @@ You can also use gdb to debug the value when the code is running.
>List some of the drawbacks of using an array instead of a vector.
1. can't add elements to an array.
2. can't use auto to deduce the type from a list of initalizers.
2. can't use auto to deduce the type from a list of initializers.
3. no arrays of references.
4. can't use template and iterator.
5. vector have lots of useful methods and algorithms.
Expand Down Expand Up @@ -228,7 +228,7 @@ The code will print "helloworld" when you run it.
because the character list in the `.rodata` like this:

h e l l o w o r l d \0
`While(*cp)` judge wether *cp is 0 or not. when *cp is not 0, it will print the character until 0.
`While(*cp)` judge weather *cp is 0 or not. when *cp is not 0, it will print the character until 0.
When you change the code like this:

const char ca[] = {'h', 'e', 'l', 'l', 'o', '\0'};
Expand Down

0 comments on commit bfe4474

Please sign in to comment.