Thread creation on a derived class method results in error

  abstract-class, boost, c++, virtual-functions

I have an abstract class as follows:

    class AbstractClass : public std::enable_shared_from_this<AbstractClass> {
    public:
        virtual ~AbstractClass() = default;

        virtual bool Start() = 0; 
        virtual void Stop() = 0;
    };

This is the derived class:

    class DerivedClass : public AbstractClass {
    public:
        bool Start() override;
        void Stop() override;
    }

I am trying to create an object of derived class a thread for the derived class method in another file:

    // Create object
    derivedClass_.reset(...);

    //Start a thread for the derived class method
    std::unique_ptr<boost::thread> derivedClassThread_;

    derivedClassThread_.reset(new boost::thread(std::bind(&DerivedClass::Start, 
    derivedClass_)));

When I compile this, I get some weird errors:

error: no type named ‘type’ in ‘class std::result_of<bool
(DerivedClass::* const&(const volatile
std::shared_ptr&))()>’

Could someone help me out?

Source: Windows Questions C++

LEAVE A COMMENT