2:23 PM
Base type to class type conversion C++ program

Develop a program to base type to class type conversion ?  Run in Dev C++

 
#include<iostream>
#include<conio.h>
using namespace std;
class avi
{
int a;
public:
avi(float x)//alwayas do conversion base to class in CONSTRUCTOR
{
a=(int)x;
}
void show()
{
cout<<"value in integer form:"<<endl<<a;
}
};
main()
{
cout<<"please enter a no."<<endl;
float b;
cin>>b;
avi a1=b;//conversion basic float b to class avi
a1.show();
}
 
Description: 
 
Enter any float value this program convert that value into integer type as program developed for. this program is developed in dev c++ software.
 
Output:
 
Please enter a no.
10.2
value in integer form:
10
Views: 163 | Added by: vijoriya | Tags: c++, Base type, class type, program, Conversion | Rating: 0.0/0
Total comments: 0
avatar