First of all, you have to understand that define is a simple replacement. This is the first point. Based on this, we will use macros to replace the two expressions you provided, and then you will understand.
You should fill in the values and calculate them, and you should understand.
First determine whether a is greater than b, then a ++ operation will be performed; when a is greater than b, the ++a expression will be returned, and a ++ operation will be performed again; what I said is a bit convoluted, I think You should know what I mean.
The solution is not to use operators in macros that will change their own values, such as ++, --, etc. This will make you dizzy.
First of all, you have to understand that define is a simple replacement. This is the first point. Based on this, we will use macros to replace the two expressions you provided, and then you will understand.
You should fill in the values and calculate them, and you should understand.
First determine whether a is greater than b, then a ++ operation will be performed; when a is greater than b, the ++a expression will be returned, and a ++ operation will be performed again; what I said is a bit convoluted, I think You should know what I mean.
The solution is not to use operators in macros that will change their own values, such as ++, --, etc. This will make you dizzy.
http://www.cnblogs.com/safeking/archive/2008/03/21/1116302.html
The minimal way to define macros without side effects (linux kernel definition)
Write them separately. Obviously, the side effects were not considered when defining the macro
@brayden’s method is useless because it is not standard C/C++ syntax
I don’t know why you have to use macros, because you said you are using C++, and obviously you should use template functions to solve this problem:
Of course, C++ has already considered this problem, so you have std::max to use.
You have to learn basic grammar. The execution logic of conditional expressions needs to be clarified
The template is great, classmate, this is Effective c++ code hahaha, I am also reading it, we can discuss with each other