I've been having trouble determining why my class header file is compiling with errors.
View the step-by-step solution to:

Question

I've been having trouble determining why my class header file is compiling with errors. (Will provide driver file

upon request)

#ifndef stopwatch_H

#define stopwatch_H

#include <iostream>

#include <conio.h>

#include <ctime>

#include <stdlib.h>

#include <time.h>

#include "stopWatch.h"

using namespace std;


class StopWatch {

private:

clock_t beginTime;

clock_t endTime;

clock_t elapsedTime;

bool stopped;

public:

StopWatch::StopWatch() {

clock_t beginTime = (unsigned int)0;

clock_t endTime = (unsigned int)0;

clock_t elapsedTime = (unsigned int)0;

bool stopped = true;

}

void StopWatch::Start() {

if (stopped == true) {

stopped = false;

beginTime = clock();

}

else

if (stopped == false) 

{

cout << "The clock is already started" << endl;

}

}

void StopWatch::Stop() {

if (stopped == false) {

stopped = true;

endTime = clock();

}

else

if (stopped == true) {

cout << "The clock is already stopped" << endl;

}

}

void StopWatch::myTimer() {

}


void myTimer::myTimer() {

startedAt = 0;

pausedAt = 0;

paused = false;

started = false;

}

void myTimer::Reset() {

paused = false;

startedAt = clock();

}


void StopWatch::DisplayTimerInfo() {

cout << "The timer started:" << beginTime << endl;

cout << "The timer ended:" < endTime << endl < endl;

elapsedTime = endTime - beginTime;

cout << fixed << setprecision(3);

cout << elapsedTime << " seconds have passed." << endl;

}

}; 

#endif

Top Answer

There are few errors in your code. 1. The code given is for class Stopwatch, there is no need to include stopwatch.h Please... View the full answer

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question