哪位大侠给解释一下这个C++程序

来源:百度知道 编辑:UC知道 时间:2024/06/04 17:17:08
#include <iostream>
class clock
{
public:
clock (int newh, int newm, int news);
void settine(int newh, int newm, int news);
void showtime ();
private:
int hour ,minute ,second;
};
clock::clock (int newh, int newm, int news)
{
hour=newh;
minute=newm;
second=news;
}
void main()
{
clock c(0,0,0);
c.showtime ();
}
编译都通不过,本人初学C++,对类的概念也比较模糊。

#include <iostream> //没有使用名称空间,推荐使用
//using namespace std;
class clock
{
public:
clock (int newh, int newm, int news);
void settine(int newh, int newm, int news); //成员函数至少要写一下它怎么工作的吧
void showtime (); //问题同上
private:
int hour ,minute ,second;//推荐先写私有成员,再写公共成员
};
clock::clock (int newh, int newm, int news)
{
hour=newh;
minute=newm;
second=news;
}
void main()
{
clock c(0,0,0);
c.showtime (); //老兄,这个showtime()你好像还没有写完吧
}