#include <iostream>
using namespace std;
////////////////////////////////////////////////////////////////
class Distance //English Distance class
{
	private:
		const float MTF; //meters to feet
		int feet;
		float inches;
	public: //constructor (no args)
		Distance() : feet(0), inches(0.0), MTF(3.280833)
		{ } //constructor (two args)

		Distance(int ft, float in) : feet(ft), inches(in), MTF(3.280833)
		{ }
		
		Distance(float meters) : MTF(3.280833)
		{ //convert meters to Distance
			float fltfeet = MTF * meters; //convert to float feet
			feet = int(fltfeet);          //feet is integer part
			inches = 12*(fltfeet-feet);   //inches is what’s left
		} //constructor (two args)
		
		void getdist() //get length from user
		{
		cout <<"\nEnter feet: "; cin >> feet;
		cout <<"Enter inches: "; cin >> inches;
		}

		void showdist() const //display distance
		{  			cout << feet << ":" << inches ; }

		operator float() const          //conversion operator
		{                               //converts Distance to meters
			float fracfeet = inches/12; //convert the inches
			//fracfeet += static_cast<float>(feet); //add the feet
			fracfeet += feet; //add the feet
			return fracfeet/MTF;                  //convert to meters
		}
		
};

main()
{
	float mtrs;
	Distance dist1 = 2.35; //uses 1-arg constructor to
	//convert meters to Distance
	cout << "\ndist1 = "; dist1.showdist();

	mtrs = dist1; //uses conversion operator
	//for Distance to meters
	cout << "\ndist1 = " << mtrs << " meters\n";
	Distance dist2(60, 0); //uses 2-arg constructor
	
	mtrs = dist2; //also uses conversion op
	
	cout << "\ndist2 = " << mtrs << " meters\n";
	// dist2 = mtrs; //error, = won’t convert
  
/*  int a;
	float f=10.54F;
	a=static_cast<int>f;
	cout<<"a = "<<a<<endl;
*/

	system("pause");
}
