User: Go all the way)
========================================================== ============
Message Group: Group/record ()
========================================================== ============
Message Type: Chat History
========================================================== ============
Ricky...
"When the priorities of Operators on both sides of an operation object are the same, then the operator's combination, also known as the combination direction or interconnectivity, determines the operation order." What is the solution?
2
I don't know what book you are reading now, but I think C ++ primer is good. You can read this book first.
2004-12-18 19:35:06
There are no mistakes in books, but a good book is usually well-understood and there will be good examples.
19:34:34 77)
Oh... it seems that my book is wrong?
19:37:35 77)
Just now, I tried my best to say, "combination is to judge who belongs to" Is that true?
19:38:17)
Only a few operators in the C language are right-aligned. Therefore, when the operators on both sides of the operand have the same priority, most operators are left-aligned ...... Simply put, it is the same as arithmetic.
2004-12-18 19:39:01 Ricky ()
A + B + C: Calculate a + B first, and then the result is + C. You don't need to make it too complicated. It should be noted that the priority is
-12-18 19:40:48 (
That's right. The premise is that you do not need to write binary code.
-12-18 19:40:57 (
[: D]
2004-12-18 19:41:19 Ricky (
If you cannot guarantee that your memory is good enough, add brackets ......
-12-18 19:42:33)
Do you want to see what the book says?
19:42:38 new C students (7)
Yes ~~~~
-12-18 19:45:48 (
A = B + C + D; the actual situation is that the C standard does not clearly define this. In some platforms or in some cases, the compiler may be like this:
A = B + (C + D );
-12-18 19:46:22 ()
For example:
A = f () + g ();
-12-18 19:47:07 ()
The compiler does not guarantee that F () must be evaluated before G.
2004-12-18 19:48:51 Ricky (
The first is incorrect. The Arithmetic Operators are both left-bound. Therefore, B + C must be first, and then the result is + D.
19:49:21 new C students ()
[: L] Can I make a mistake?
2004-12-18 19:49:48 Ricky (1)
Tan haoqiang's book has many errors.
-12-18 19:50:20 ()
Int I = 0;
While (I <10)
Arraytarger [I] = arraysource [I ++];
Yes:
While (I <10)
{Arraytarget [I] = arraysource [I];
++ I ;}
2004-12-18 19:51:39 Ricky ()
In fact, only the single object operator, the conditional operator, and the value assignment combine the right operator, and the others combine the left operator.
-12-18 19:52:32 ()
Although I ++ returns the I value before auto-increment, the problem is that the compiler of some platforms cannot guarantee that the bitwise operation is performed before auto-increment:
Arraytarger [I]
-12-18 19:53:37 ()
The Ricky example is specifically mentioned in the book.
-12-18 19:53:59 (
Use the c99 standard.
2004-12-18 19:54:06 Ricky (1)
Well, if you don't mind, you can look at Lippman's essential C ++
-12-18 19:54:43 ()
[: '(] No book. You have to find it.
19:55:20 new C students ()
You have a compilation mechanism in your hand. I need to buy a book here.
-12-18 19:57:05 ()
The last example is 89 years. Sorry.
19:58:11,-12-18)
This book is biased towards C and does not know whether C ++ is the same as C.
-12-18 20:04:19 (
Why can't I speak?
-12-18 20:04:31 (
[?]
20:04:46 new C students (
[: 8] I don't know the combination right now...
Is the combination of an operator and an operation object on the right? A ** P is equivalent to a * (* P )?????
-12-18 20:05:18 (
Wait
2004-12-18 20:05:47 Ricky (
This is not an operator, it is a type definition, it is another case.
A ** P indicates that p is a pointer to a * type.
-12-18 20:05:58 (
In fact, I think this book means that the combination and operation order are two different things.
2004-12-18 20:06:31 Ricky (
The same principle
Const int * p, p is a pointer, pointing to the const int type
Int * const p, p is a pointer constant, pointing to the int type
-12-18 20:06:39 (
There are contacts but different
2004-12-18 20:06:58 Ricky (
Int const * P is equivalent to const int * P
20:07:07 there is no snow in heaven (
Haha
2004-12-18 20:07:15 Ricky (
In actual programming, priority issues are more common.
20:07:20 there is no snow in heaven (
A ** P
2004-12-18 20:07:35 Ricky (
Avoid writing code that is easy to get misunderstood.
20:07:35 new C students (
[: 8] unhappy
-12-18 20:08:23 (
Ricky [:)]
2004-12-18 20:08:42/Kun meteor shower (
[?]
2004-12-18 20:08:45 Ricky (1
Correct the error ,:)
20:08:57 new C students (
A ** P indicates that p is a pointer to a * type.
-----------------------------
Int * P;
A * (* P?
20:09:50 there is no snow in heaven (
[Strong]
7 (take the tianyao Road) 20:06:53
This is a combination problem.
Beginner in c) 20:11:09
The eldest brother redefined the concept of associativity? I am dizzy ~~~~~
20:12:11 (Meteor Shower)
Just listen
(Ricky) 20:12:12
Sorry, this is the expression, but there is no doubt, it is obviously a * (* P), because the priority level of the bitwise operator is higher than that of the arithmetic operator.
(Go all the way) 20:08:41
The example in this book is about the sequence of operation under the same priority machine.
Of course, the order and combination of operations are closely related to the priority.
(Beginner c) 20:14:39
How does Ricky talk about associativity? My entire concept has been overturned.
(Two yuan and two yuan respectively)
Ricky) 20:15:37
Associativity are a simple thing. You think about it too complicated. Think about how to calculate expressions in arithmetic.
(There is no snow in heaven) 20:18:24
Have you ever met: Is A + B * C calculated in this way (a + B) * C just calculated in our primary school mathematics. Why is it so complicated, something is related to the environment you are using.
(Ricky) 20:19:24
Except single object operators, conditional operators, and value assignment operators, all operators are left to right. A + B-C, that is, add and subtract first, and define int ** P, then ** P = 5; that is, * (* P) = 5, first, take the int pointer pointed to by P, and then take the content of the pointer, because * is a single object operator, which is first right and then left
(Beginner c) 20:22:05
The so-called combination should be to combine operators and computing objects?
(Ricky) 20:23:42
Here is a "*". Do you know whether it is multiplication or content? They must all be placed in a specific environment. When you write code at the beginning, you can honestly add brackets if you are not sure about it.