我定义了三个文件
file1:date_header.h
namespace Chrono
{
class Date
{
public://公共界面
enum Month{jan=1,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec};
........
Date(int dd=0,Month mm=Month(0),int yy=0);//0的意思是“取默认值”
.......
private:
int d,y; //表示
Month m;
static Date default_date;
};
}
file2:date_implement.cpp
#include"date_header.h"
#include<iostream>
using namespace std;
using namespace Chrono;
Date Date::default_date(22,feb,1901);//初始化static数据成员
Date::Date(int dd,Month mm,int yy)//构造函数
{.........}
...............
void Date::display(Date &d)const//显示日期
{
cout<<d.d<<" "<<d.m<<" "<<d.y<<endl;
}
file3:main.cpp
#include"date_header.h"
void main()
{
using namespace Chrono;
Date d;
Date::display(d);
}
编译错误:D:\programe\the c++ programming language\t\main.cpp(9) : error C2352: 'Chrono::Date::display' : illegal call of non-static member function
d:\programe\the c++ programming language\t\date_header.h(24) : see declaration of 'display'
请帮忙,谢谢,