还是不懂
#include "myfunctions.h"
#include <iostream>
using namespace std;
class Time
{
public:
Time(int,int,int);
mutable int hour;
mutable int minute;
int sec;
void get_time() ;
};
Time::Time(int h,int m,int s)
:hour(h),minute(m),sec(s)
{}
void Time::get_time()
{
cout<<hour<<":"<<minute<<":"<<sec<<endl;
}
int main()
{
Time t1(12,5,6);
Time t2(8,25,12);
t1.get_time();
t2.get_time();
const Time * p=&t1;
p->hour=18; //现在p所指向的内容应该是常量吧!但为什么这里还是能改值呢?
p->get_time();
t2.get_time();
return 0;
}