2dix-The Student Choice
Log in Register now

Base type to class type conversion C++ program

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

(By Dr. Ayush Vashishtha )

#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

comments (2)

avatar
1
smile thank you Dr. Ayush Vashishtha
avatar
2
hello guys good work
avatar