title: Compile Errors in Class with User Defined Functions
body: <p>I am trying to build a class that stores a user-defined function inside of it for later use. I have decided to use the <code>boost::function</code> object to do so.</p>
  
  <p>However, I get the following error on compile:</p>
  
  <p><code>error: no match for ‘operator=’ in ‘((SomeClass*)this)-&gt;SomeClass::someFunction = ((SomeClass*)this)-&gt;SomeClass::DefaultFunction’</code> </p>
  
  <p>I do not understand this error, since someFunction and DefaultFunction should, as far as I can see, have the same types.</p>
  
  <p>The code is shown below: </p>
  
  <pre><code>#include &lt;boost/function.hpp&gt;
  
  class SomeClass{
      private:
              boost::function&lt;int(int)&gt; someFunction;
              int DefaultFunction(int i);
  
      public:
              SomeClass();
              ~SomeClass();
              void SetFunction(int (*f)(int));
      };
  
  int SomeClass::DefaultFunction(int i){
      return i+1;
  
  }
  
  SomeClass::SomeClass(){
      someFunction=DefaultFunction;
  }
  
  ~SomeClass::SomeClass(){
  
   }
  
   void SomeClass::SetFunction(int (*f)(int i)){
          someFunction=f;
   }
  
   void MyProgram(){
          SomeClass s;
   }
  </code></pre>
  
  <p>Can anyone offer any pointers as to how to construct such an object? Alternatively, iff there is a better way than the one I am attempting, could you explain it to me?</p>
  
  <p>Kindest regards!</p>