Wednesday, September 21, 2016

Class To Basic Type Conversion

Tags

Program To Convert Class Type To Basic Type:

#include<iostream>
using namespace std;
class s
{
    int feet;
    float inches;
    public:
        s()
        {
            cout<<"Enter Distance in Feet And Inches\n";
            cin>>feet>>inches;
        }
        operator float()
        {
        float ft=inches/12;
        ft=ft+feet;
        return(ft/3.28);
        }
       
};
main()
{
    float m;
    s t;
    m=t;
    cout<<"Distance In Meter Is "<<m;
   
}