N
N
Nikolay Nozdrin-Plotnitsky2015-04-02 13:38:39
Qt
Nikolay Nozdrin-Plotnitsky, 2015-04-02 13:38:39

Why is a method called from an inherited class in Qt?

class MyClass : public QThread
{
   MyClass(unsigned long ms) { time = ms; start();}
   void run(){ while(true) { cycle();msleep(time);}}
   void cycle() { qDebug() << "Hello MyClass";}
private:
   unsigned logn time;
}

class MyClass2 : public MyClass
{
   MyClass2() : MyClass(100) {}
   void cycle() { qDebug() << "cycle...";}
}

When run, outputs "Hello MyClass". And after all should "cycle..." or I do not understand something?
The program simply creates an object of class MyClass2.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vitaly, 2015-04-02
@scientistnik

virtual

V
Vladimir Martyanov, 2015-04-02
@vilgeforce

You would write how and what you call, what you get and what you want to get. Without it, the answer is "Because".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question