Question 1.

Posted: August 29, 2012 in Lab 5, Uncategorized
#include<iostream.h>
class DB;
class DM{
float m;
public :
DM (){}
DM(float met)
{
m=met;
}
void show()
{
cout<<"\n METERS="<<m;
}
DM::DM(DB m1);
friend DM operator+(DM b1,DM b2);
};
class DB{
float f,i;
public :
DB(){}
DB(float ft,float in)
{
f=ft;
i=in;
}
DB(DM b1);
friend DM::DM(DB m1);
};

DM::DM(DB m1)
{
m=(m1.f*12+m1.i)/39.37;
}

DM operator+(DM b1,DM b2)
{
float a=b1.m+b2.m;
return (a);
}

 main()
{
 DM d1(3),d3(5),d;
 DB d2(2,1),d4(4,2);
 d=d1+d2;
 d.show();
 d=d2+d1;
 d.show();
 d=d1+d3;
 d.show();
 d=d2+d4;
 d.show();
 }
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s