0

need help about c++

i recieve an errir in my program.

5th Sep 2017, 7:06 AM
Imran Ali
Imran Ali - avatar
4 odpowiedzi
+ 1
can you post the Code
5th Sep 2017, 7:26 AM
promise orazulike
promise orazulike - avatar
0
using namespace std; class time24 { private: int hours; int minutes; int seconds; public: time24() : hours(0),minutes(0),seconds(0) { } time24(int h,int m,int s) : hours(h),minutes(m),seconds(s) { } void display(const) { if(hours<10) cout<<"0"; cout<<hours<<": "; if(minutes<10) cout<<"0"; cout<<minutes<<":"; if(seconds<10) cout<<"0"; cout<<seconds<<":"; } int gethrs() const {return hours;} int getmins() const {return minutes;} int getsecs() const {return seconds;} }; class time12 { private: bool pm; int hrs; int mins; public: time12() :pm(true),hrs(0),mins(0) { } time12(time24); time12(bool ap, int h, int m) : pm(ap),hrs(h),mins(m) { } void display() const { cout<<hrs<<":"; if(mins<10) cout<<"0"; cout<<mins<<' '; string am_pm=pm ? "p.m." : "a.m."; cout<<am_pm; } }; time12::time12(time24 t24) { int hrs=t24.gethrs(); pm=t24.gethrs()<12 ? false:true; mins=(t24.getsecs()<30)? t24.getmins():t24.getmins()+1; if(mins==60) { mins=0; ++hrs24; if(hrs == 12||hrs == 24) pm=(pm==true)?false:true; } hrs=(hrs24<13)?hrs24:hrs24-12; if(hrs==0) {hrs=12;pm=false; } } int main() { int h,m,s; while (true) { cout<<"enter 24 hour format time: "<<endl; cin>>h; if(h>23) return(1); cout<<" minutes "; cin>>m; cout<<" seconds "; cin>>s; time24 t24(h,m,s); cout<<"you entered : "; t24.display(); time12 t12=t24; cout<<"\n12 hour time: "; t12.display(); cout<<endl; } return 0; }
5th Sep 2017, 7:27 AM
Imran Ali
Imran Ali - avatar
0
here is the code...
5th Sep 2017, 7:27 AM
Imran Ali
Imran Ali - avatar
0
wow thats a nice but no matter how i try to look at. but there are some errors....but check thoo. will advise to run in a true Compiler. will point out The errors.. class 12 {private.................. time12():pm(true),hrs(0),mins(0) {} time12(time24); time 12(bool ap); int h, m; pm(ap) //ap here wasn't Declared and also not a type time12 does not have any field named *pm* or *hrs* or *mins* nd others just run it in a compiler
5th Sep 2017, 8:52 AM
promise orazulike
promise orazulike - avatar