63,594
社区成员




#include <iostream>
using namespace std;
#if !defined(AFX_DATE_H__91F06C7A_00D0_410C_86AE_0C76D3E71326__INCLUDED_)
#define AFX_DATE_H__91F06C7A_00D0_410C_86AE_0C76D3E71326__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CDate
{
friend ostream& operator<<( ostream&, const CDate& );
public:
CDate(int = 2008, int = 1 ,int = 1);
CDate(const CDate &);
void setDate(int, int, int);
void setYear(int );
void setMonth( int );
void setDay ( int );
int getYear() const;
int getMonth() const;
int getDay() const;
bool isLeapYear( int ) const;
void nextDay();
virtual ~CDate();
private:
int year, month, day;
int checkDays( int, int , int);
};
ostream& operator<< ( ostream& output, const CDate& d)
{
output<< "Year: " << d.getYear() << " Month: " << d.getMonth() << " Day: " << d.getDay() << endl;
return output;
}
struct test {
void fun() {
}
};
2) inline函数
inline ostream& operator<< ( ostream& output, const CDate& d)
{
output<< "Year: " << d.getYear() << " Month: " << d.getMonth() << " Day: " << d.getDay() << endl;
return output;
}
ps:建议不要写在.h