class Decoder {
public:
virtual void run() {}
//...
}
Now, I have this derived class:
class NVDecoder : public Decoder
{
public:
void run();
which is defined as this in the NVDecoder.cpp file
void NVDecoder::run()
{
//...
}
As the function void of Decoder
is virtual
, doing:
//Decoder decoder = new NVDecoder();
auto decoder = std::make_shared<NVDecoder>(NVDecoder::NALU,Decoder::H264);
decoder->run();
should call the NVDecoder
's run function, not the Decoder
's one. However, when I start a thread for a generic Decoder
object, I need to do like this:
auto decoderThread = std::make_shared<std::thread>(&Decoder::run, decoder);
This calls the Decoder
's run function, not the NVDecoder
's one. I guess it's because I pass &Decoder::run
. How do I start a thread that uses the NVDecoder
's run
function without passing &NVDecoder::run
?