.


:




:

































 

 

 

 


.




 

● ==:

//

inline bool operator == (const Date & d1, const Date & d2)

{ return d1.GetYear() == d2.GetYear() &&

d1.GetMonth() == d2.GetMonth() &&

d1.GetDay() == d2.GetDay();}

(==), (!=). , . , .

● !=:

//

inline bool operator == (const Date & d1, const Date & d2);

//

inline bool operator!= (const Date & d1, const Date & d2)

{ // -

return!(d1 == d2); }

(<, <=, >, >=). , - (<), (==). .

class Date

{ //

public:

// 4

bool operator < (const Date & d) const;

bool operator <= (const Date & d) const;

bool operator > (const Date & d) const;

bool operator >= (const Date & d) const;

};

//

bool Date::operator < (const Date & d) const

{ // ,

if (m_Year < d.GetYear())

return true;

// -

else if (m_Year == d.GetYear())

{ // , , ,

if (m_Month < _d.GetMonth())

return true;

// , ,

else if (m_Month == _d.GetMonth())

return m_Day < _d.GetDay();

// ,

// ( return false )

}

// ,

return false;

}

// :

//

bool Date::operator > (const Date & d) const

{ return d < * this;}

// :

// => ,

// => ( >)

bool Date::operator <= (const Date & d) const

{ return (* this < d) || (* this == d);}

// :

// => ,

// => ( <)

bool Date::operator >= (const Date & d) const

{ return (d < * this) || (* this == d);}

. , , -, . < (BST).

, , , , - , , . , - , , , ..

, :

● , -, ( , )

● , ( ).

, +, += .. - , . .

, . . ++ - (overloading overloaded operators). , , / . .

 

15. , /. .

2 - , . . - .

 

 

//

int IntegerArrayPtr:: operator * () const

{

// - bool

assert(* this);

 

// -

return m_pData[ m_currentPosition ];

}

 

//*******************************************************************************

 

//

int & IntegerArrayPtr:: operator * ()

{

// - bool

assert(* this);

 

//

return m_pData[ m_currentPosition ];

}

 

int IntegerArrayPtr:: operator [] (int _index) const

{

// - bool

//

assert(* this && (m_currentPosition + _index) < m_length);

 

// -

return m_pData[ m_currentPosition + _index ];

}

 

//*******************************************************************************

 

//

int & IntegerArrayPtr:: operator [] (int _index)

{

// - bool

//

assert(* this && (m_currentPosition + _index) < m_length);

 

//

return m_pData[ m_currentPosition + _index ];

}

 

 

/ . , , .

 

/ . . . . , .

 

, int. , . -,

 

//

IntegerArrayPtr& IntegerArrayPtr:: operator ++ ()

{

//

assert(* this);

 

// 1

++ m_currentPosition;

 

// ,

return * this;

}

 

// -

IntegerArrayPtr IntegerArrayPtr:: operator ++ (int)

{

//

assert(* this);

 

// ,

IntegerArrayPtr copy(* this);

 

// 1

++ m_currentPosition;

 

//

return copy;

}

 

//

IntegerArrayPtr& IntegerArrayPtr:: operator -- ()

{

//

assert(* this);

 

// 1

--m_currentPosition;

 

// ,

return * this;

}

 

//*******************************************************************************

 

// -

IntegerArrayPtr IntegerArrayPtr:: operator -- (int)

{

//

assert(* this);

 

// ,

IntegerArrayPtr copy(* this);

 

// 1

-- m_currentPosition;

 

//

return copy;

}

 

 

:

 

, 2 :

● -:

○ , this;

○ - this , ;

, .

 

// :

// =>

// =>

IntegerArrayPtr:: operator bool () const

{

return m_currentPosition < m_length;

}

 





:


: 2016-07-29; !; : 958 |


:

:

, ,
==> ...

1289 - | 1255 -


© 2015-2024 lektsii.org - -

: 0.033 .