谢谢回复。我想完成下面一些操作:
typedef struct {
long
mjd;
double
fracOfDay;
}
MJD;
class
DateTime
{
friend ostream &operator<<( ostream &output, DateTime &dt );
public:
// constructors
DateTime();
DateTime( Time time );
// destructor
~DateTime();
// initializers
void
SetTime( Time time );
// selectors
GPSTime
GetTime();
// manipulators
const DateTime &operator=(const DateTime &DT2);
DateTime* operator&(DateTime input);
DateTime operator + ( const double days );
double
operator - ( const DateTime &DT2 );
bool
operator == ( const DateTime &DT2 );
bool
operator != ( const DateTime &DT2 );
bool
operator >
( const DateTime &DT2 );
bool
operator >= ( const DateTime &DT2 );
bool
operator <
( const DateTime &DT2 );
bool
operator <= ( const DateTime &DT2 );
private:
long
mjd;
double
fractionOfDay;
};
DateTime* DateTime::operator&(DateTime input)
{
return &input;
}
// const return avoids: (a1 = a2 ) = a3
const DateTime &DateTime::operator=(const DateTime &DT2)
{
if( &DT2 != this ) // avoids self assignment
{
mjd = DT2.mjd;
fractionOfDay = DT2.fractionOfDay;
}
return *this;
}