SORU
2 EKİM 2010, CUMARTESİ


Nasıl sonek ve önek için iki farklı şekilde operatör aşırı yükleme için?

Nasıl postfix için aşırı yükleme iki farklı şekilde operatör a a önek?

CEVAP
2 EKİM 2010, CUMARTESİ


Bu gibi görünmelidir:

class Number 
{
    public:
        Number& operator   ()     // prefix   
        {
           // Do work on this.   (increment your object here)
           return *this;
        }

        // You want to make the    operator work like the standard operators
        // The simple way to do this is to implement postfix in terms of prefix.
        //
        Number  operator   (int)  // postfix   
        {
           Number result(*this);   // make a copy for result
             (*this);              // Now use the prefix version to do the work
           return result;          // return the copy (the old) value.
        }
}; 

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Jose LviS el Bambino ( JLB )   LviSito

    Jose LviS el

    3 ŞUBAT 2008
  • Visual Life

    Visual Life

    3 Temmuz 2006
  • William Hyde

    William Hyde

    23 HAZİRAN 2008