恩恩,我又来提问了
#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就不会报错,能解决吗
#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就不会报错,能解决吗
...全文
相关推荐
恩智浦智能车资料
"恩智浦智能车资料"是一份非常宝贵的资源,它主要针对的是参与恩智浦智能车大赛的参赛者。
恩智浦智能车摄像头组国赛程序
【标题】"恩智浦智能车摄像头组国赛程序"涉及的是在智能车竞赛中使用的摄像头系统,由著名半导体公司恩智浦(NXP)提供技术支持。
恩山新版中兴Telnet工具体验版-20230830.rar
二、恩山新版中兴Telnet工具的特点1. 用户友好的界面:恩山新版中兴Telnet工具注重用户体验,提供了直观的图形化界面,使得即使是对命令行不太熟悉的用户也能轻松上手。2.
恩智浦智能车电磁组国二程序
在智能车竞赛中,"恩智浦智能车电磁组国二程序"是一个关键的资源,尤其对于参赛者来说,能够提供宝贵的实践经验和技术指导。
恩智浦信标组代码加PCB
【标题】"恩智浦信标组代码加PCB"涉及的是在智能车竞赛中,参赛队伍使用恩智浦半导体的微控制器技术进行信标导航系统的设计与实现。


