c++ - Does C style casting adds assembly (code) or is it only for the compiler to understand the situation? -


class  { public:  *geta(void) { return a; }  protected:  *a;  };  class b : public { public:  b *getb(void) { return (b*)a; }  }; 

in class assume compiler (ideally) optimize , inline getter no different code accessing variable directly ?

in class b variable cast b. purely compiler or involve code ? assembly instructions same function in b ?

most casts not insert assembler instructions, however, there exceptions:

  1. expanding casts on signed integers: cast inserts sign extension instruction preserve value of negative values.

  2. casts , floating point types: these casts perform full conversion, not reinterprete bits. consequently, computer has something.

  3. pointer casts multiple inheritance. while first base first member in object, second base can't be. so, casting derived* secondbase* adjust pointer, adding addition instruction code.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -