by Dinesh Thakur Category: Array Pointer and Union

 

#include<iostream.h>

#include<conio.h>
     class dist
{
     private:
                   int feet;
                   double inches;
    public:
                   void get()
                     {
                            cout<<"Enter feet & inches";
                            cin>>feet>>inches;
                     }
                  void show()
                    {
                           cout<<"Addition"<<feet<<"."<<inches<<" ";
                }
                           dist add(dist);
 };
             dist dist::add(dist h2)
          {
                  dist tt;
                  tt.feet=feet+h2.feet;
                  tt.inches=inches+h2.inches;
                  if(tt.inches>=12.00)
                    {
                           tt.feet++;
                           tt.inches-=12.00;
                    }
                           return(tt);
          }
                void main()
       {
                 clrscr();
                 dist obj1 ,obj2,obj3;
                 obj1.get();
                 obj2.get();
                 obj3=obj1.add(obj2);
                 obj3.show();
                 getch();
       }

Returning Objects For Addition Of Distances



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.



Related Articles