Question: MilTime.h : #include using namespace std; #ifndef _MilTime_h #define _MilTime_h //Include the header file. #include Time.h //Define the class. class MilTime : public TimeProblem4 {
MilTime.h : #include using namespace std; #ifndef _MilTime_h #define _MilTime_h //Include the header file. #include "Time.h" //Define the class. class MilTime : public TimeProblem4 { //Define the member variables. private: int milHours; int milSeconds; int hour; int sec; //Define the member functions. public: MilTime(int hours, int seconds) { milHours = hours; milSeconds = seconds; } void setTime(int mhours, int mseconds); int getHour(); int getStandHr(); }; #endif TimeProblem4.cpp #include "TimeProblem4.h" #include #include #include "stdafx.h" using namespace std; int TimeProblem4::gethour() const { return hour; } int TimeProblem4::getSec()const { return sec; } TimeProblem4.h #ifndef TIMEPROBLEM4_H #define TIMEPROBLEM4_H class TimeProblem4 { protected: int hour; int min; int sec; public: Time () { hour = 0; min = 0; sec = 0; } TimeProblem4 (int h, int m, int s); int gethour () const; int getMin() const { return min; } int getSec() const; }; #endif main problem .cpp #include #include #include "MilTime.h" #include "TimeProblem4.h" using namespace std; int main() { int hr, sec; MilTime time1(0, 0); cout << "Enter Time in Military format:"; cin >> hr; sec = hr % 10; time1.setTime(hr, sec); cout << "MilitaryFormat:" << time1.getHour() << "hours" << endl; if (time1.getHour() >= 1300) { cout << "Standard Format:" << time1.getStandHr() << ":"; if (time1.getMin() == 0) { cout << time1.getMin() << "0" << "PM" << endl; } else cout << time1.getMin() << "PM" << endl; } else { cout << "Standard Format:" << time1.getStandHr() << ":"; if (time1.getMin() == 0) { cout << time1.getMin() << "0" << "AM" << endl; } else cout << time1.getMin() << "AM" << endl; } system("pause"); return 0; } MilTime.cpp #include #include #include "Time.h" #include "MilTime.h" #include "stdafx.h" using namespace std; void MilTime::setTime(int mhours, int mseconds) { if (mhours < 2359 && mhours>0 && sec <= 59 && sec >= 0) { milHours = mhours; mseconds = mseconds; hour = (milHours / 100); min = milHours % 100; sec = milSeconds; } else { cout << "Incorrect input of the" << " military format "; system("pause"); exit(0); } } int MilTime::getHour() { return milHours; } int MilTime::getStandHr() { return hour % 12; } In milTime.h the program is having an issue. Its saying "Expected class-name before "{"
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
