function inside functor definition
<p>I have the following functor for redefining the less operator of the sort method for the vector type:</p>

<pre><code>typedef vector&lt; vector&lt;int&gt; &gt; MxInt2d;
typedef vector&lt; vector&lt;double&gt; &gt; MxDouble2d;

class QSweep{   
public:
....
static MxDouble2d myPoints_;
    MxDouble2d myEdges_;

class order{
public:
 bool operator() (const vector&lt;int&gt;&amp; edge1, const vector&lt;int&gt;&amp; edge2){
  //std::cout&lt;&lt;"inside sort"&lt;&lt;endl;
  //3 sort criteria
  return (myPoints_[edge1[0]][0]&lt;myPoints_[edge2[0]][0])|| 
                           (myPoints_[edge1[0]][0]==myPoints_[edge2[0]][0]&amp;&amp; 
                            myPoints_[edge1[0]][1]&lt;myPoints_[edge2[0]][1]) 
         ||
          (myPoints_[edge1[0]][0]==myPoints_[edge2[0]][0]&amp;&amp; 
                             myPoints_[edge1[0]][1]==myPoints_[edge2[0]][1]&amp;&amp; 
           getSlope(myPoints_[edge1[0]][0],myPoints_[edge1[0][1],  
                                      myPoints_[edge1[1]][0],myPoints_[edge1[1]][0])
           &lt;
                             getSlope(myPoints_[edge2[0][0],myPoints_[edge2[0][1],    
                                      myPoints_[edge2[1]][0],myPoints_[edge2[1]][0]));
   }
};
static double getSlope(double a, double b, double c, double d);

};
</code></pre>

<p>where getSlope is a function defined in the following way:</p>

<pre><code>double QSweep::getSlope(double a, double b, double c, double d){
double slope=0.0;
//std::cout&lt;&lt;"slope criteria"&lt;&lt;endl;
double denum=c-a;
if (denum==0){
 std::cout&lt;&lt;"zero denominator"&lt;&lt;endl;
}
else{
 slope=(d-b)/denum;
}
return slope;
}
</code></pre>

<p>Each point is given by an index, an x, and a y coordinate; Each edge is given by source-edge[0] and destination-edge[1],where edge[0],edge[1] are indexes of the points).
I want to arrange the edge:
- by the x coordinate of their edge[0] coordinate (iff the x's of 2 edges are different)
- by the y coordinate of their edge[0] coordinate (iff the x's of 2 edges are equal)
- by their corresponding slopes (iff the x's of edges and the y's of edges are equal).</p>

<p>I declared the getSLope function static, but when I sort the edges with</p>

<pre><code>    sort(myEdges_.begin(),myEdges_.end(),order());
</code></pre>

<p>the last condition is not fullfilled.
if I have two edges with the same x's and y's for edgep[0] but with different slopes, e.g. slope(edge1)=1 ,slope(edge2)=1/2 than I would want to get 
[edge2, edge1]; instead I get [edge1,edge2].
So my getSlope criteria is not computed.</p>

<p>is it because I declared getSlope static? what should I change so that the criteria is fulfilled?
thank you in advance for your suggestions,
madalina</p>
