Stupid compiler error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • rollasoc

    Stupid compiler error

    Hi,

    Made me laugh so I though I'd share this.

    short i = 32;
    short j = 1;
    short k = i + j;

    gives an error
    Cannot implicitly convert type 'int' to 'short'

    That is a bit poo in my reckoning...

    at least the following compiles.

    short k = (short)(i + j);



  • Malik Arykov

    #2
    Re: Stupid compiler error

    Hello, rollasoc!

    r> short i = 32;
    r> short j = 1;
    r> short k = i + j;

    int k = i + j; // Ok


    Comment

    • Morten Wennevik

      #3
      Re: Stupid compiler error

      You will get the same if you try

      byte = byte + byte;

      I wonder why

      --
      Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

      Comment

      • rollasoc

        #4
        Re: Stupid compiler error

        Indeed true

        but that won't work when I the call a C++ function expecting a short.


        "Malik Arykov" <arykov@r40.nal og.ru> wrote in message
        news:##2xxlluDH A.4056@TK2MSFTN GP11.phx.gbl...[color=blue]
        > Hello, rollasoc!
        >
        > r> short i = 32;
        > r> short j = 1;
        > r> short k = i + j;
        >
        > int k = i + j; // Ok
        >
        >[/color]


        Comment

        Working...