如何用c++设计一个钟表类

如何用c++设计一个钟表类,包括时分秒,使用构造函数初始化数据成员

#include<iostream>
#include<string.h>
using namespace std;

class clocks {
    
    

public:
    clocks(float t, float  m, float s) :time(t), minute(m), second(s) {};
    float  time=0;
    float  minute=0;
    float  second=0;

    void out() {
        cout << "现在是" << time << "时" << minute << "分" << second << "秒";
    }

};


int main() {
    
    clocks c1(12, 5, 32);
    c1.out();

    return 0;
}

结果:

img


望采纳