by Dinesh Thakur Category: Classes in C++

 

#include <iostream.h>

#include<conio.h>
union chng_byte
{
    void chng();
    void set_byte(unsigned short i);
    void show_word();
    unsigned short u;
    unsigned char c[2];
};
          void chng_byte::chng()
        {
            unsigned char t;
            t=c[0];
            c[0] = c[1];
            c[1] = t;
        }
          void chng_byte::show_word()
        {
             cout <<u;
        }
          void chng_byte::set_byte(unsigned short i)
       {
              u =i;
       }
           void main()
       {
           clrscr();
           chng_byte s;
           s.set_byte( 49034);
           s.chng();
           s.show_word();
           getch();
       }
Output :
35519
About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Search Content







Popular Article