Hi All,
I'm having troubles achieving something, I need to call an overriden method from the base class as follow :
I thought this way the binding is done at runtime, and the method of the base class is called but this is not what I'm getting !!Code:class Base{ public: void start(){ new thread(boost::bind(&Base::run, this)); } virtual void go(){ // do something } } class Derived : public Base { public: void go(){ //do something different } } int main(int argc, char** argv){ Derived* der = new Derived(); der->start(); return 0; }
Just to discard the boost::bind, I tried this as well :
OS : windowsCode:class Base{ public: void start(){ new thread(boost::ref(*this)); } virtual void go(){ //do something. } void operator()(){ this->go(); } } class Derived : public Base { public: void go(){ //do something different } } int main(int argc, char** argv){ Derived* der = new Derived(); der->start(); return 0; }
COMPILER : gcc
am I doing something wrong ?
thanks in advance.
BR




Reply With Quote