Pages

Tuesday, October 11, 2011

5.Operator Overloading

WAP USING OPERATOR OVERLOADING TO ENTER THE MEMORY IN BYTES AND CONVERT THEM INTO MB,KB & BYTES


#include<iostream.h>
#include<conio.h>
class memory
{
long int b,kb,mb;
public:
memory(long int d)
{
b=d%1024;
d=d/1024;
kb=d%1024;
d=d/1024;
mb=d%1024;
}

void disp()
{
cout<<"MB::"<<mb<<endl
    <<"KB::"<<kb<<endl
    <<"Bytes::"<<b;

}
};

void main()
{
clrscr();
long int bt;
cout<<"Enter the memory in bytes::";
cin>>bt;
memory m=bt;
m.disp();
getch();
}

No comments: