/*************************************************************************************
J_3_P_5
Write a meaningful C++ program, which shows the use of user-defined to basic type data
conversion.
**************************************************************************************/
#include <iostream.h>
#include <conio.h>
class date
{
int day, month, year;
public:
void getdata()
{
cout << "Enter day = ";
cin >> day;
cout << "Enter month = ";
cin >> month;
cout << "Enter year = ";
cin >> year;
}
operator int()
{
int totalday;
totalday = year * 365 + month * 30 + day;
return totalday;
}
};
void main()
{
int totalday;
clrscr();
date obj;
obj.getdata();
totalday = obj;
cout << "\n\tTotal Day = " << totalday;
getch();
}
Comments
Post a Comment