Why can't I write cout<<a==b; but can write cout<<(a==b);

mohammad monjezi

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?

Thomas Sablik

<< 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] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

cout << a == b; 그러나 cout << (a == b);

분류에서Dev

Why can't I write to the file mmaped

분류에서Dev

Why can't I write to this buffer?

분류에서Dev

Why can't I convert DynamicJson to my class if I don't write {get; set;}

분류에서Dev

I can't write object literal notation in Dev Console?

분류에서Dev

why char* why not bool* can be used in write function in c++ file I/O

분류에서Dev

Can I filter a returned JSON by <b> tag?

분류에서Dev

Can't write to flash drive unless root

분류에서Dev

How can I wait for the write of a file?

분류에서Dev

C++ File I/O--can't read/write simultaneously?

분류에서Dev

Can I write to the USB stick that I'm running Ubuntu from?

분류에서Dev

Why shouldn't I directly access Instance properties for write operations?

분류에서Dev

Can't ping Subnet A from Subnet B with router between them

분류에서Dev

bash throws "set-ena" when I press/write b in the terminal

분류에서Dev

WordPress on LinuxMint: Can't create directory (or write file)

분류에서Dev

Can't get PHP script to write user input to text file

분류에서Dev

How can I write into the browser´s console via Blazor WebAssembly?

분류에서Dev

Can I write test cases for AngularJS service using Jasmine spy?

분류에서Dev

Can I have a "write once run forever" kind of system in Java?

분류에서Dev

How can I write the code to get all the properties of a class?

분류에서Dev

Can I write a CoffeeScript lib the same way for the server and client?

분류에서Dev

I am trying to write a query but can seem to think of a way to do it

분류에서Dev

How can I Write an Event that Happens when Mouse Scrolls in TextBox?

분류에서Dev

Can I write more than one structure in file?

분류에서Dev

How can I write space in Terminal on OS X?

분류에서Dev

How can I write this function without using a modulo?

분류에서Dev

Can I write different types of messages to a chronicle-queue?

분류에서Dev

How can I ignore previous selection and write only last selected

분류에서Dev

How can I get javascript to write dates in my input boxes?

Related 관련 기사

  1. 1

    cout << a == b; 그러나 cout << (a == b);

  2. 2

    Why can't I write to the file mmaped

  3. 3

    Why can't I write to this buffer?

  4. 4

    Why can't I convert DynamicJson to my class if I don't write {get; set;}

  5. 5

    I can't write object literal notation in Dev Console?

  6. 6

    why char* why not bool* can be used in write function in c++ file I/O

  7. 7

    Can I filter a returned JSON by <b> tag?

  8. 8

    Can't write to flash drive unless root

  9. 9

    How can I wait for the write of a file?

  10. 10

    C++ File I/O--can't read/write simultaneously?

  11. 11

    Can I write to the USB stick that I'm running Ubuntu from?

  12. 12

    Why shouldn't I directly access Instance properties for write operations?

  13. 13

    Can't ping Subnet A from Subnet B with router between them

  14. 14

    bash throws "set-ena" when I press/write b in the terminal

  15. 15

    WordPress on LinuxMint: Can't create directory (or write file)

  16. 16

    Can't get PHP script to write user input to text file

  17. 17

    How can I write into the browser´s console via Blazor WebAssembly?

  18. 18

    Can I write test cases for AngularJS service using Jasmine spy?

  19. 19

    Can I have a "write once run forever" kind of system in Java?

  20. 20

    How can I write the code to get all the properties of a class?

  21. 21

    Can I write a CoffeeScript lib the same way for the server and client?

  22. 22

    I am trying to write a query but can seem to think of a way to do it

  23. 23

    How can I Write an Event that Happens when Mouse Scrolls in TextBox?

  24. 24

    Can I write more than one structure in file?

  25. 25

    How can I write space in Terminal on OS X?

  26. 26

    How can I write this function without using a modulo?

  27. 27

    Can I write different types of messages to a chronicle-queue?

  28. 28

    How can I ignore previous selection and write only last selected

  29. 29

    How can I get javascript to write dates in my input boxes?

뜨겁다태그

보관