#include <iostream>
#include <stdio.h>
using namespace std;
class Time
{
public:
Time(int h=1,int m = 2,int s = 3)
{
hour = h;
minute = m;
second = s;
}
void set_time();
friend void show_time(Time&);
private:
static int p;
int hour;
int minute;
int second;
};
int Time::p = 12;
int main()
{
Time st1(12,46,23);
Time st2(st1);
show_time(st2);
cout << Time::p << endl;
cout << st1.p << endl;
cout <<st2.p << endl;
return 0;
}
void show_time(Time &t)
{
cout << t.hour << ":" << t.minute << ":" << t.second << endl;
}
将static int p;放在私有区就报错,放在共有区就行,我用的是mingw编译器,是codeblocks自带的,但是用vs2012就不会报错,能解决吗