#include<iostream.h>
#include<fstream.h>
#include<conio.h>
class Distance
{
int feet;
int inches;
public:
friend istream& operator>>(istream &in,Distance &d);
friend ostream& operator<<(ostream &out,Distance &d);
};//End of class
fstream file;
istream& operator>>(istream &in,Distance &d)
{
cout<<endl<<"Enter distance(feet inches): ";
in>>d.feet>>d.inches;
file.write((char*)&d,sizeof(d));
return in;
}
ostream& operator<<(ostream &out,Distance &d)
{
file.seekg(0);
file.read((char*)&d,sizeof(d));
out<<"Distance is: "<<d.feet<<" feet and "<<d.inches<<" inches!";
return out;
}
int main()
{
Distance d1,d2;
clrscr();
file.open("D:/arjun.txt",ios::out|ios::in);
cin>>d1;
cout<<d2;
file.close();
getch();
return 0;
}
getch();
nice
ReplyDeleteThanks for it i would pass just brcause u....................
ReplyDeletePost a Comment