Thursday, April 22, 2010

c++ - conversion from class hour to minute and vice-versa

#include"iostream"
using namespace std;
class year;
class month
{
int m;
public:
//month(){m=0;}
month(int month){m=month;}
month(year);

operator year();
void show()
{
cout "month= " m endl;
}
};
class year
{
int y;
public:
year(){y=0;}
year(int year){y=year;}
int ye(){return y;}
void show()
{
cout "year=" y endl;
}


};
month::operator year()
{
int a;
a=m/12;
return year(a);
}
month::month(year oy)
{
int i;
i=oy.ye();
m=i*12;
}


int main()
{
year o;
month o1(36);
o1.show();
o=o1;
o.show();
o=2;
o.show();
o1=o;
o1.show();
system("pause");
return 0;
}

No comments:

Post a Comment