FRIEND FUNCTION PROGRAM
CREATE TWO CLASSES dm AND db WHICH STORE THE VALUE OF DISTANCE. WRITE A PROGRAM THAT CAN READ VALUES FOR THE CLASS OBJECTS AND ADD ONE OBJECT OF dm WITH ANOTHER OBJECT OF db. USE A FRIEND FUNCTION TO CARRY OUT THE ADDITION OPERATION OBJECT THAT STORES THE RESULT MAY BE IN dm OBJECT OR db OBJECT DEPENDING ON THE UNITS ON WHICH THE RESULTS ARE REQUIRED. THE DISPLAY SHOULD BE IN THE FORMAT OF FEET AND INCHES OR METERS AND CENTIMETERS DEPENDING ON THE OBJECT ON DISPLAY. C++ PROGRAM: #include <iostream> #include <stdlib.h> using namespace std; // '& # 0 9 1 ;' is third left bracket class DB; class DM { float c1, c2, inc1; int m, cm, ft1; public: void m_cm(){ cout<<"M= "; cin>>m; cout<<endl<<"CM= "; cin>>cm; cout<<endl; } void convart1() { m=m*100; c1=m+cm; c2=c1*0.4; ft1=c2/12; inc1= c2-(ft1*12); } friend void add1(DM,DB); friend void add2(DM,DB); }; class DB