如题,书上说类定义时不占存储空间,无法直接对数据成员初始化,但试了一下好像可以,是我书太旧了吗??
#include<iostream>
using namespace std;
class Time {
private:
int hour=0;
int minute=0;
int second=1;
public:
void show_time(void);
};
Time t1;
int main() {
t1.show_time();
}
void Time::show_time(void) {
cout << hour << ":" << minute << ":" << second;
}