恩恩,我又来提问了
#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就不会报错,能解决吗
...全文
相关推荐
恩智浦智能车资料
资料非常有用,对于恩智浦智能车大赛会有很大的帮助。
恩智浦智能车摄像头组国赛程序
恩智浦智能车竞赛十二届国赛程序,稳定速度3.2m,实验室速度更快,根据个人水平,提升空间还很大。注释详细,适合新手,同样适合老鸟。
恩山新版中兴Telnet工具体验版-20230830.rar
恩山新版中兴Telnet工具体验版_20230830.rar
恩智浦智能车电磁组国二程序
本人2017智能车国二,亲测可跑,可以识别圆环等自己加的小想法,应该对写程序有一点启发作用,采用B车车模,采用K60芯片,但是传感器信号处理可以参考,特别是舵机pd,电机pid,挺有价值的
恩智浦信标组代码加PCB
恩智浦杯智能车信标组


