[C++] does implicit type conversion happen during compile-time or run-time

Discussion in 'Computer Programming, Emulation, and Game Modding' started by Nyap, May 16, 2016.

  1. Nyap
    OP

    Nyap HTML Noob

    Banned
    973
    344
    Jan 13, 2016
    That Chaos Site
    my tutorial keeps saying that it's the compilers doing but I just want to make sure
     
  2. Nyap
    OP

    Nyap HTML Noob

    Banned
    973
    344
    Jan 13, 2016
    That Chaos Site
    is it so hard to write one word
     
  3. 0x40

    0x40 GBAtemp Regular

    Member
    224
    63
    Apr 20, 2013
    The compiler basically adds the casts for you when needed. The following program:
    Code:
    #include <stdio.h>
    int main() {
        int a = 2;
        char b = 'b';
        printf("%i", a + b);
    
        return 0;
    }
    will compile into the exact same executable when the cast is explicit:

    Code:
    #include <stdio.h>
    int main() {
        int a = 2;
        char b = 'b';
        printf("%i", a + (int)b);
    
        return 0;
    }
     
  4. Nyap
    OP

    Nyap HTML Noob

    Banned
    973
    344
    Jan 13, 2016
    That Chaos Site
    ah ok thnx
     
    0x40 likes this.