c++ - Controlling an object using a functor : efficiency, modularity? -


good evening,

consider following code :

class controlled;  //============================================================================  class controller { public:     explicit    controller( controlled* c ) : mcontrolled( c ) { }     void        update( const time dt ) { /* stuff */ }      template<class t>     void        apply( t fn );  private:     controlled* mcontrolled; };  template<class t> void entitycontroller::apply( t fn ) {     fn( mcontrolled ); }  //============================================================================  class controlledupdate_f { public:     controlledupdate_f( const time dt ) : mtime( dt ) { }     void operator()( controlled* c ) { /* stuff */ } private:     time mtime; }; 

of 2 update() fonctions, 1 part of controller class , functor 1 more efficient ? how ? secondly, functor system more modular other 1 ? see doing using scripting engine.

thank time. apologize in advance if question has obvious answer.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -