Semicolon after Function

后端 未结 6 1475
广开言路
广开言路 2021-02-18 12:57

Is there a specific reason why some people put a semicolon after the curly closing function bracket?

void foo() {

};
6条回答
  •  迷失自我
    2021-02-18 13:44

    The semicolon must follow the class definition curly closing bracket. It is not required after class member functions definitions inside of the class definition. It is required though after class member functions declarations alone inside of the class definition.

    #ifndef FRAME_COUNTER_H
    #define FRAME_COUNTER_H
    
    #include 
    
    #include 
    
    const Uint32 FPS = 60;
    const Uint32 DELAY_TIME = 1000.0f / FPS;
    
    
    class FrameCounter {
    
    public:
        FrameCounter();
    
        void setFPS(int FPS) { m_FPS = FPS / (m_frameAccumulator / 1000); }
    
        void start() { m_frameStart = SDL_GetTicks(); }
    
        void run();
    
        void reset() {}
    
        void print() { printf("\nFPS: %5.1f\n", m_FPS); }
    
    private:
        int m_frameNumber;
    
        Uint32 m_frameStart;
        Uint32 m_frameDuration;
        Uint32 m_frameAccumulator;
    
        double m_FPS;
    };
    
    #endif
    

提交回复
热议问题