Friday, 27 April 2012
Program Of Type Conversion Between Derive to Base Class
#include <iostream.h>
#include<conio.h>
class Base
{
private:
double b;
public:
B
ase(double x)
{
b=x;
}
void display()
{
cout<<"\n Base Class Value Is"<<b;
}
double getValue()
{
return b;
}
};
class derive
{
private:
int d;
public:
derive(int y)
{
d=y;
}
void display()
{
cout << "\n derive Value Is"<<d;
}
operator Base()
{
return Base(d*1.609344);
}
};
main()
{
clrscr();
derive m1 = 100;
// Source Class
Base k1 = m1;
// Destination Class
m1.display();
k1.display();
cout << endl;
getch();
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment