The above error is occurring on the line where I implement my constructor. I made a comment that points to that line. Any help greatly appreciated.
#include <vector>
#include <time.h>
class Stopwatch
{
enum state {UNSTARTED, RUNNING, PAUSED, FINISHED};
struct time
{
unsigned hours;
unsigned minutes;
unsigned seconds;
};
struct lap
{
unsigned n; // lap number
time t; // lap time
lap* next_ptr;
};
public:
Stopwatch();
~Stopwatch();
void right_button(); // corresponds to start/stop/pause
void left_button(); // corresponds to lap/reset
private:
state cur_state;
std::vector<lap> lapsvec;
}
Stopwatch::Stopwatch() // <--------- Here's where the compiler error is
{
cur_state = UNSTARTED;
}
/* trivial destructor */
Stopwatch::~Stopwatch()
{
}
int main()
{
return 0;
}
I reviewed C++ constructors to see if I could figure out the problem. No luck.
You need a ;
after the class declaration. Since you don't have it, the class is not yet declared when the compiler reaches Stopwatch::Stopwatch()
, thus complaining it's a new type.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With