SORU
22 Mayıs 2015, Cuma


Ne yapar:?

2 Ders var:

class base {
    virtual void foo() {};
};

class derived : public base {
    void foo() { base::foo(); }
};

Bir hata yaptım ve base::foo(); yerine base:foo(); yazdı. Kod derlenmiş ve çalıştırmak, ama segfaulted.

Google ve ne olduğunu bilmiyorum nasıl olduğunu bilmiyorum, ama çok merak ediyorum: Bu ne anlama geliyor?

base:foo();

Önemli ise:

class base : public QAbstractGraphicsShapeItem

CEVAP
22 Mayıs 2015, Cuma


void foo() { base:foo(); }

eşittir:

void foo()
{
   base: // An unused label.
   foo(); // Calls the function again, resulting in infinite recursion.
}

Sonsuz özyineleme nedeniyle, işlevi yığın taşması neden olur.

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

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Bokeh

    Bokeh

    9 HAZİRAN 2014
  • Damien Hayes

    Damien Hayes

    11 Mart 2008
  • Showtime

    Showtime

    21 HAZİRAN 2006