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?
相关阅读
我给两位转点伪币, 过年可以了么?来,讨论个问题ipv6地址和ipv4地址不是同一个ip?谁有现在contractor的hourly rate吗?换个话题,当你发现一个牛顿级别的学霸错了,你该怎么办?客观总结vert.x又有Script#程序员被干掉了这次Scala又被吐槽了,too complex请科普Cloud的企业应用为什么无论Java还是Ruby,转成Node代码量都是几十倍的减少呢?明白为啥 12306 没人接了在写一个java小程序,求算法,10个包子答谢我最近写ruby写得很开心机械硬盘的物理极限C++, Java, & Python 在Google的使用JavaScript ,j2ee哪个工资高 有前景?有什么课是用PYTHON 语言讲算法的? (转载)JAVA programmer = car driver问一个读写锁的问题股版世纪大赌局,征3位湾区人士见证goodbug吃屎了!!! (转载)