b*d
2 楼
int i = 1;
int j = 2;
int k = i +++ j;
k?
i?
j?
int j = 2;
int k = i +++ j;
k?
i?
j?
v*d
3 楼
...
v*d
5 楼
怎么换另一个形象啊 我换衣服了啊
怎么还是这个
怎么还是这个
v*d
7 楼
。。。
l*8
8 楼
The parser/tokenizer will always try to match the longest string. Therefore
when it encounters a sequence of "i+++j" it will generate four tokens:
(1) identifier "i"
(2) operator "++"
(3) operator "+"
(4) identifier "j"
when it encounters a sequence of "i+++j" it will generate four tokens:
(1) identifier "i"
(2) operator "++"
(3) operator "+"
(4) identifier "j"
v*d
9 楼
,,
v*d
11 楼
晕 不会用
v*d
13 楼
now
b*d
14 楼
that's totally true.
so i++j is wrong, but i+ +j is okay.
Therefore
【在 l***8 的大作中提到】
: The parser/tokenizer will always try to match the longest string. Therefore
: when it encounters a sequence of "i+++j" it will generate four tokens:
: (1) identifier "i"
: (2) operator "++"
: (3) operator "+"
: (4) identifier "j"
so i++j is wrong, but i+ +j is okay.
Therefore
【在 l***8 的大作中提到】
: The parser/tokenizer will always try to match the longest string. Therefore
: when it encounters a sequence of "i+++j" it will generate four tokens:
: (1) identifier "i"
: (2) operator "++"
: (3) operator "+"
: (4) identifier "j"
t*t
16 楼
it is defined in C++ standard, but your reason is wrong
it is defined in the tokenization process.
【在 b*****d 的大作中提到】
: In fact, it is defined in C++ standard.
: The reason is i++ has higher precedence than ++i.
: Surprisingly.
: so, i +++ j is
: (i++)+j rather than
: i+ (++j).
: VS 2008 gives the correct answer.
it is defined in the tokenization process.
【在 b*****d 的大作中提到】
: In fact, it is defined in C++ standard.
: The reason is i++ has higher precedence than ++i.
: Surprisingly.
: so, i +++ j is
: (i++)+j rather than
: i+ (++j).
: VS 2008 gives the correct answer.
w*i
19 楼
somehow remind me of 茴香豆的茴字有几种写法, hehe
l*8
20 楼
>> how about i +++j
No, "i +++j" is still tokenized as "i", "++", "+", "j".
This has nothing to do with operator precedence.
To force the parser to recognize (++j), you need to put a space between the 1st and 2nd
"+", like this: "i+ ++j".
No, "i +++j" is still tokenized as "i", "++", "+", "j".
This has nothing to do with operator precedence.
To force the parser to recognize (++j), you need to put a space between the 1st and 2nd
"+", like this: "i+ ++j".
m*e
22 楼
Wow...
I think it's good to know stuff, but this is very close to useless knowledge
to me.
the 1st and 2nd
【在 l***8 的大作中提到】
: >> how about i +++j
: No, "i +++j" is still tokenized as "i", "++", "+", "j".
: This has nothing to do with operator precedence.
: To force the parser to recognize (++j), you need to put a space between the 1st and 2nd
: "+", like this: "i+ ++j".
I think it's good to know stuff, but this is very close to useless knowledge
to me.
the 1st and 2nd
【在 l***8 的大作中提到】
: >> how about i +++j
: No, "i +++j" is still tokenized as "i", "++", "+", "j".
: This has nothing to do with operator precedence.
: To force the parser to recognize (++j), you need to put a space between the 1st and 2nd
: "+", like this: "i+ ++j".
l*8
23 楼
You probably will never care about this problem unless your job is to write
a compiler... So yes, it is 99.9% useless.
a compiler... So yes, it is 99.9% useless.
d*n
26 楼
who will actually write this?
maybe some tester?
maybe some tester?
相关阅读
纽约法院强制封杀DVDFABc++就像一个贼船C++最大的弱点是违反人性C10M 练习 step 1: 10M socketsINTEGER搜索求建议软件速度也可以是生死攸关的事情。JAVA还是挺可爱的$1500的domain,我耽误两天,被一个老印买去了gmail和hotmail的区别请问大牛做科学计算用什么语言合适?移动互联网:综述书籍/资料C10M除了socket以外,还牵涉其他方面的技巧大牛们说说为什么我那么钟意node?其实C++是一块试金石Target CIO力主外包烙印。 讽刺! (转载)自己看c++是不是夕阳语言有没有c 或者 c++ 做的 web server Framework?坛子里有人搞HBase的吗?有码工的地方就有是非啊哪位大侠给推荐个scientific plotting lib/software (转载)