Question
I'm facing a new error in my code that I'm stuck with in C++: Here is my code with 3 files. CLOCK.H CLOCK.CPP #include Clock.h
I'm facing a new error in my code that I'm stuck with in C++:
Here is my code with 3 files.
CLOCK.H
CLOCK.CPP
#include "Clock.h" #include
Clock::Clock(bool format_24) { time_t seconds = time(0); localtime_s; d_hours = 0; d_secs = 0; d_mins = 0; this->format_24 = format_24; }
void Clock::addHours(int hours) { d_hours += hours; }
void Clock::addMinutes(int mins) { d_mins += mins; }
void Clock::addSeconds(int secs) { d_secs += secs; }
void Clock::resetClock() { d_hours = 0; d_secs = 0; d_mins = 0; }
void Clock::displayTime(ostream& out) { int seconds = 0, minutes = 0, hours = 0; seconds = localTime->tm_sec + d_secs; minutes += (seconds / 60); seconds = seconds % 60;
minutes += localTime->tm_min + d_mins; hours += minutes / 60; minutes = minutes % 60;
hours = (hours + localTime->tm_hour + d_hours) % 24; string timestr = ""; out 12) { out
And CLOCKDEMO.CPP
#include "Clock.h" #include
void menu() { cout
int main() { Clock clock12(false), clock24(true); int choice; bool exit = false; while (!exit) { cout > choice; switch (choice) { case 1: clock12.addHours(1); clock24.addHours(1); break; case 2: clock12.addMinutes(1); clock24.addMinutes(1); break; case 3: clock12.addSeconds(1);
I believe that localtime_s is the big issue but everywhere I look asks me to use localTime = localtime(&seconds); which did nothing but make it impossible for me to make a .exe file for the project. Any clues or tips?
C Microsoft Visual Studio Debug Console U:\Project1\Debug\Project1.exe (process 21080) exited with code -1073741819. Press any key to close this window ... Clock.cpp Clock.h x ClockDemo.cpp Project1 (Global Scope) 4 in #includeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started