by Dinesh Thakur Category: Classes in C++

 

#include<iostream.h>

#include<conio.h>
 class height
{
    private:
                      int f;
                      double i;
    public:
                      height(int f1 )
               {
                      f=f1 ;
                      i=0.0;
               }
                     height(double f1)
               {
                     f=int(f1 );
                     i=(f1-int(f1 ))*12.0;
               }
                     height()
               {
                     f=i=0;
                }
                     height(int f1 ,double in)
               {
                     f=f1 ;
                     i=in;
               }
                     void show()
               {
                     cout<<"Feet = " <<f<<" inches = " <<i<<"\n";
                }
};
          void main()
     {
          clrscr();
          height obj1 ,obj2,obj3;
          obj1 =height(2);
          obj2=height(3.5);
          obj3=height(6,3);
          obj1.show();
          obj2.show();
          obj3.show();
          getch();
     }

Height class



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