0

The question is within the code.

#include <iostream>

int main()
{
   typedef unsigned char uchar;
   uchar u = ~uchar();

   // The following line, at least using gcc, prints: -1 �
   // The rvalue it's printed as a number, and the lvalue as a character.
   // What's the explanation of this behaviour for this particular type?
   std::cout << ~uchar() << ' ' << u << std::endl;

   return 0;
}
ABu
  • 10,423
  • 6
  • 52
  • 103
  • Because the returning type of the built-in operator~ is int. – 273K Feb 17 '20 at 23:19
  • Types are different - that the explanation - `int` in the first case and `unsigned char` in the second, it is not related to lvalue or rvalue – Slava Feb 17 '20 at 23:24

0 Answers0