2:29 PM
Program to class type to base type conversion using constructor c++ program

Develop a Program to class type to base type conversion using constructor c++ program (developed in dev c++ ).

(by Dr. Ayush Vashishtha)
 
#include<iostream>
#include<conio.h>
using namespace std;
class avi
{
int a;
public:
avi()
{};
avi(int x)
{
a=x;
}
operator float()
{
float b=a;
return (b/2.2);
}
};
main()
{
avi a1(10);
float m=a1;
cout<<m;
        getch();
}
 
Output:
 
 4.54545
Views: 128 | Added by: vijoriya | Tags: Conversion, Base type, C++ Program, program, constructor, class type | Rating: 0.0/0
Total comments: 0
avatar