Class error

Whenever I try to us my timer class I get this error:
I:\CodeBlocks\Games\SDL\Events\main.cpp|69|error: could not convert '{false}' from '<brace-enclosed initializer list>' to 'Timer'|

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
  class Timer
{
    public:
        bool paused;
        int currentticks;
        Timer() : paused(false), currentticks(0), pausedticks(0) {startticks=SDL_GetTicks();}
        void PauseUnpause_Timer()
        {
            switch(paused)
            {
                case true:
                    currentticks=SDL_GetTicks()-pausedticks;
                    paused=false;
                default:
                    pausedticks=SDL_GetTicks()-startticks;
                    paused=true;
            }
        }
        void GetTime_LOOP()
        {
            switch(paused)
            {
                case false:
                    currentticks=SDL_GetTicks()-startticks;
                    break;
                default:
                    break;
            }
        }
        int GetSeconds()
        {
            return currentticks/1000;
        }
    private:
        int startticks;
        int pausedticks;
};

int main
{
    Timer testtimer={false};
}


Timer testtimer={false}; What are you trying to do here? Timer class does not have initialization list constructor defined like error says, so this line is malformed;
I fixed it, all I needed to use was an initializer list.

Timer() : paused(false), currentticks(0), pausedticks(0) {startticks=SDL_GetTicks();}

Turns into:

Timer(bool paused) : paused(false), currentticks(0), pausedticks(0) {startticks=SDL_GetTicks();}
Topic archived. No new replies allowed.