by Dinesh Thakur Category: Classes in C++

 

#include <iostream.h>

#include<conio.h>
class Height
{
  private:
                 int feet;
                 float inches;
  public:
                 Height() :feet(0), inches( 0.0) {}
                 Height(int ft,float in):feet(ft),inches(in){}
                 void get()
            {
                     cout <<"\n Feet";
                     cin >>feet;
                     cout <<" inches:";
                     cin >>inches;
            }
                void show()
           {
                     cout <<feet <<" - " <<inches;
           }
};
          void main()
     {
              clrscr();
              Height H1(6,4.0);
              Height H2(H1);
              Height H3 =H1;
              cout <<"\nHeigh1 =";H1.show();
              cout <<"\nHeigh2 =";H2.show();
              cout <<"\nHeigh3 =";H3.show();
              cout <<endl;
              getch();
     }

Default Copy Constructor

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.



Search Content





Popular Article