i just read my book and it says union members share the same memory. like a long and a double will both occupy the same block of 8 bytes (the biggest member of the union). why would anyone want to do that? please explain in detail about unions.....and give some example because all my book gave me was:
and it says unions can be use in classes...why wouldnt anyoneCode:union shareLD { double dval; double lval; }; shareLD myUnion; myUnion.dval = 5.4; myUnion.lval = 5; // dval has been overwritten // or unions can be written like this union shareDLF { double dval; long lval; float fval; } uinst = {1.5};
want to use unions when they could use "new" and "delete"?



LinkBack URL
About LinkBacks


