Practical - 23
#include<iostream>
using namespace std;
class T12
{
int h,m;
char c;
public:
T12()
{
h=0;
m=0;
c='\0';
}
void getdata()
{
cout<<"\n Enter the time according to 12 hour";
cout<<"\n enter no of hour : ";
cin>>h;
cout<<"\n enter no of minitues : ";
cin>>m;
cout<<"\n enter a for a.m or p for p.m : ";
cin>>c;
}
friend class T24;
};
class T24
{
int ho,mi;
public:
T24()
{
ho=0;
mi=0;
}
T24(T12 t1)
{
if(t1.c == 'p')
{
ho = t1.h + 12;
mi = t1.m;
}
else
{
ho = t1.h;
mi = t1.m;
}
}
friend void disp(T24);
};
void disp(T24 t2)
{
cout<<"\n hour : "<<t2.ho;
cout<<"\n minitues : "<<t2.mi;
}
int main()
{
T12 t1;
T24 t2;
t1.getdata();
t2=t1;
disp(t2);
return 0;
}
using namespace std;
class T12
{
int h,m;
char c;
public:
T12()
{
h=0;
m=0;
c='\0';
}
void getdata()
{
cout<<"\n Enter the time according to 12 hour";
cout<<"\n enter no of hour : ";
cin>>h;
cout<<"\n enter no of minitues : ";
cin>>m;
cout<<"\n enter a for a.m or p for p.m : ";
cin>>c;
}
friend class T24;
};
class T24
{
int ho,mi;
public:
T24()
{
ho=0;
mi=0;
}
T24(T12 t1)
{
if(t1.c == 'p')
{
ho = t1.h + 12;
mi = t1.m;
}
else
{
ho = t1.h;
mi = t1.m;
}
}
friend void disp(T24);
};
void disp(T24 t2)
{
cout<<"\n hour : "<<t2.ho;
cout<<"\n minitues : "<<t2.mi;
}
int main()
{
T12 t1;
T24 t2;
t1.getdata();
t2=t1;
disp(t2);
return 0;
}
No comments:
Post a Comment