(Test environment is WINDOWS8 under vs2013)
1-1 is the following definition correct? Why?
1-2 is the following definition correct? If not, why?
A: The compilation result of vs2013, 1-1 is correct, 1-2 is wrong, the wrong hint
Usage of "+":
First + can only connect two string types or a string type and a direct amount of strings, followed by a left-associative.
So the first one is OK, because Hello is a string type, with "world" after the combination of string type, followed by "! "Combined
And the second one is wrong, because "hello" and "world" are the direct amounts of strings.
1-3 are the following procedures correct? If it's right, what does it do? If not, why?
Let's look at the results of the operation:
There is no problem with running the result, so the program is correct because "{}" is a living space and the first S is released after the first curly brace ends
1-4 are the following programs right? What happens if we change the last third line} to};
After rewriting:
The result of the operation is the same, or curly braces for the existence of space problems, as well as the role of semicolons, but added an empty statement
1-5 are the following procedures correct? If it's right, what does it do? If not, say the reason and rewrite it correctly.
After compilation
Yes, because X is in the third bracket, so there is no X in the second layer, and to output X, you have to put them in the same living space.
It's like this:
Since S is defined in the second bracket, if there is no new definition of s in the third layer, then S is defined by the second layer, which is less of a rewrite, and allows all of them to be in a living space:
1-6 when the following program asks you to enter, you enter two names (for example, Samuel Beckett). How will it handle it? Predict the results before running the program and try again.
is a variable name is assigned two times to print separately, the result
The first chapter of accelerated C + + Practice