#include <iostream>
using namespace std;
class clock
{
public:
clock(int newh, int newm, int news) :h(newh), m(newm), s(news) {
newh = h;
newm = m;
news = s;
};
/*void settime(int newh, int newm, int news)
{
};*/
inline void showtime()
{
cout << h << ":" << m << ":" << s << endl;
};
private:
int h, m, s;
};
int main() {
clock c(0, 0, 0);
c.showtime();
return 0;
}
相比较于书中的案例,可以直接在类的内部进行定义,不必要在类外定义,并且从定义语法上来看也可以直接省略一个函数的创建,更为简便一些!