I know ()
has higher precedence than <<
, and <<
has higher precedence than ==
, but I want to know why I can't write cout<<a==b;
yet can write cout<<(a==b);
in C++.
How the compiler translates cout<<a==b;
and then shows error?
<<
has higher precedence than ==
as you can see here.
The statement
cout<<a==b
is equivalent to
(cout<<a)==b
The expression
cout<<a
returns a stream. This stream is compared to b
. If there is no left shift operator for a stream and a
or no comparing operator for a stream and b
this causes a compiler error
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다