title: pure virtual method called error
body: <p>I have the following definitions:</p>
  
  <pre><code>class PartitioningMethod {
  public:
    virtual void addConstraints(ConstraintManager&amp; cm) = 0;
    virtual bool hasMoreConstraints() = 0;
    virtual void setQuery(const Query&amp; q) = 0;
    virtual ~PartitioningMethod(){ }
  };
  
  
  class Random : public PartitioningMethod {
  private:
    vector&lt; ref&lt;Expr&gt; &gt; constraints;
    vector&lt; ref&lt;Expr&gt; &gt;::iterator it;
    vector&lt; ref&lt;Expr&gt; &gt;::iterator end;
    int numConstraints;
    RNG theRNG;
  
  public:
    void setQuery(const Query&amp; q) { 
  
      constraints.clear();
  
      //Set random number
      //srand ( unsigned ( time (NULL) ) * theRNG.getInt32() );
      srand ( theRNG.getInt32() );
  
      //Copy constraints    
      copy(q.constraints.begin(),q.constraints.end(),std::back_inserter(constraints));
  
      //Shuffle Randomly
      std::random_shuffle(constraints.begin(),constraints.end(), p_myrandom);
  
      it = constraints.begin();
      end = constraints.end();
      numConstraints = constraints.size();
    }
  
    void addConstraints(ConstraintManager&amp; cm) {
      int step = rand() % numConstraints + 1;
      while(step != 0) {
        cm.addConstraint(*it);
        ++it;
        --step;
        --numConstraints;
      }   
    }
  
    bool hasMoreConstraints() {
      return it != end;
    }
  };
  
  
  bool PartitioningSolver::computeInitialValues(const Query&amp; query,
                              const std::vector&lt;const Array*&gt; &amp;objects,
                              std::vector&lt; std::vector&lt;unsigned char&gt; &gt; &amp;values,
                              bool &amp;hasSolution) {
  
    fprintf(stderr,"INIT\n");  
    // If there are no constraints in the query
    if(query.constraints.size() == 0 || query.constraints.size() == 1)
      return solver-&gt;impl-&gt;computeInitialValues(query, objects, values, hasSolution);
  
    // If the number constraints in the query are &gt; 0 
    method-&gt;setQuery(query);
  
    ConstraintManager cm;
    ref&lt;Expr&gt; expr = query.expr;
  
    fprintf(stderr,"Begin partitioning\n");
    fprintf(stderr,"---------------------\n");  
  
    while(method-&gt;hasMoreConstraints()){
      fprintf(stderr, "HERE");
      //Add Constraints
      method-&gt;addConstraints(cm);
  
      //Construct a query
      Query temp_query(cm,expr);
  
       ExprPPrinter::printQuery(std::cerr,temp_query.constraints,temp_query.expr); 
       fprintf(stderr,"---------------------\n");
  
      //Query STP to check if satisfiable
      values.clear(); 
  
      if(!solver-&gt;impl-&gt;computeInitialValues(temp_query, objects, values, hasSolution))
        return false;
  
      //If not, return immediately (a win!) 
      if(!hasSolution)
        return true; 
  
      //If a solution is returned, check if the solution satisfies the entire set of constraints
      vector&lt;const Array*&gt; obj = objects;
      Assignment solution(obj, values);
      bool satisfiesAll = checkSolution(solution, query.constraints);
  
      //  fprintf(stderr,"Satisfies all: %i\n", satisfiesAll);
  
      // If it is successful, return the solution (a win again!), 
      if(satisfiesAll)
        return true;
  
      // If not add more constraints (if there is more) and repeat
    }
    return true;
  }
  </code></pre>
  
  <p>A Partial definition for the Partitioning solver class:</p>
  
  <pre><code>class PartitioningSolver : public SolverImpl {
  private:
    Solver*             solver;
    PartitioningMethod* method;
    bool checkSolution(Assignment&amp; solution,  const ConstraintManager&amp; constraints);  
  public:
    PartitioningSolver(Solver *s,  PartitioningMethod* pm) : solver(s), method(pm) { }
    ~PartitioningSolver() { delete solver; delete method; }
  };
  </code></pre>
  
  <p>Sorry for pasting such a long snippet of code but I have been working on it for hours and keep getting the eror</p>
  
  <pre><code>pure virtual method called
  terminate called without an active exception
  </code></pre>
  
  <p>I am not sure what's wrong. It seems to fail in computeInitialValues function where <code>fprintf(stderr,"Begin partitioning\n");</code> is located. I tried adding print statements as a last resort but even they don't print anything.. Any ideas is appreciated.</p>
  
  <p>EDIT:<br>
  Ok so I changed the name Random to Ran and it started to work. I was creating this class instance on the fly as an argument with new Random() I guess it was mixing up with another constructor or something else I dont know..</p>