#include <iostream>
using namespace std;
#include "Interface.h"


void timer::start()
{
    if(! running)
    {
        begin=(unsigned int) clock();
        running=true;
    }
}

void timer::end()
{
    if(running)
    {
        finish=(unsigned int) clock();
        running=false;
    }
}

int timer::elapsed()
{
    if(running)
    {
        return((unsigned int) clock()-begin);
    }
    else
    {
        return finish-begin;
    }
}

int timer::output(unsigned int seconds)
{
    return seconds >= elapsed();
}

It says undefined reference to '_WinMain@16'

Edited 3 Years Ago by Reverend Jim: Fixed formatting

Comments
24 posts, and STILL hasn't figured out code tags :(

You created a windows application project and don't have a WinMain function. WinMain is the entry point for windows applications. If you're writing a program that uses main instead of WinMain, change the project type to a console application. If you really do want a windows application, there has to be a WinMain function somewhere in your .cpp files.

all this is is a class. you need to implement it in an actual program.

int main()
{
     timer Timer;
     //use the timer here
     return 0;
}

I'm assuming you have the actual class in "Interface.h" and that these are just the functions.

If the only error you get is undefined reference to winmain() then you did everything in your class right. All that error is telling you is that you don't have a main() or winmain() function for the program to start in. that will go away when you write a program that uses your class.

This article has been dead for over six months. Start a new discussion instead.