我在。
class Thread
{
public:
static void *entry (void *pvArg) { Thread *pobjThread = static_cast<Thread *> (pvArg); pobjThread->run (); }
virtual void run (void) = 0;
};
我有2个阅读班:
class Item : public Thread
以及
class Product : public Thread
<代码>>>>>项目代码>从该功能的构造者处起,该功能的构造者将打入校正图书馆,以创建“<代码>> 输入/编码”和“<代码>>><>ts作为pvArg
,而
Now the thing is, class Item
works fine. The run
function is called 以及 processes correctly. However, when class Product
calls the same function later, I get:
pure virtual method called
Both class have the same implementation with overloading the run
method, but one is called 以及 the other is not.
为什么我突然获得“<条码>封面法”称为“条码>例外?
感谢。
Update:
class Item
is different the class Product
because Item
is declared as a static Item item;
in the cpp file 以及 there is only one. class Product
is used like a normal object. If I do the same thing to class Product
it works fine.