gcc compiler error "enable to find reference to vtable". i ‘ve got this error even if all my pure virtual and non-pure virtual functons are outof line

  c++, gcc

i got the "enable to find reference to vtable" error from gcc for a specific class.

error from gcc

i was doing some kind of backtraking problem and i have my backtracking template(hh), my calss definition (hh) e the function (cc). i’ve got also the main and the data.hh, data.cc but i truly think that the problem is in the backtracking part. i searched around and find a lot of advice to put at least one non-pure virtual method out of line, but in fact, i ve got all of them out of line so i dont find a solution. The algorithm part is fine, im pretty sure, the problem is just the error from gcc, which i cannot correct in any way.
here i show the backtracking part, first the template and his costructor:

using namespace std;

template <typename Input, typename Output, typename CFtype>
class BacktrackingOpt
{
public:
  BacktrackingOpt(const Input& i, unsigned fl);
  bool Search();
  Output BestSolution() { return best; }
  unsigned NumNodes() const { return count; }
protected: 
  virtual void GoDownOneLevel() { level++; }
  virtual void GoUpOneLevel(){ level--; }
  virtual void FirstOfLevel() = 0;
  virtual bool NextOfLevel() = 0;
  virtual bool AtRootLevel() { return level == -1; }
  virtual bool FullSolution() { return level == final_level; }
  virtual bool Feasible() = 0;
  virtual bool NonImprovingBranch() { return false; }
  virtual CFtype Cost() = 0;
  int level, final_level;
  unsigned count;
  CFtype cost, best_cost;  
  const Input& in;
  Output out, best;
};

template <typename Input, typename Output, typename CFtype>
BacktrackingOpt<Input,Output,CFtype>::BacktrackingOpt(const Input& i, unsigned fl) 
  : in(i), out(in), best(in) 
{ 
  count = 0;
  level = -1; 
  final_level = fl; 
}

here i show my class:

class FSSP_Backtracking : public BacktrackingOpt<FSSP_Input, FSSP_Output, unsigned>
{
 public:
  FSSP_Backtracking(const FSSP_Input& in, unsigned fl);  
 protected:
  // hot-spots
  void FirstOfLevel() override;
  bool NextOfLevel() override;
  bool Feasible() override;
  unsigned Cost() override;
  // cold-spots
  void GoDownOneLevel() override;
  void GoUpOneLevel() override;
  bool NonImprovingBranch() override;
  
  vector<vector<unsigned>> remaining_jobs; 
  vector<unsigned> current_job; 

};

finally here we have the .cc with the definition of all the override method of the last class, i show this because i dont know the source of the problem not because you have to understande the code of course.

FSSP_Backtracking::FSSP_Backtracking(const FSSP_Input& in, unsigned fl) 
   : BacktrackingOpt(in,fl), current_job(in.Jobs(), 0) 
{
  remaining_jobs.resize(in.Jobs());
  for (unsigned l = 0; l < in.Jobs(); l++)
    remaining_jobs[l].resize(in.Jobs());
}

void FSSP_Backtracking::FirstOfLevel()
{ 
  current_job[level] = 0;
  out[level] = remaining_jobs[level][current_job[level]];
  out.ComputeTimes();
}

bool FSSP_Backtracking::NextOfLevel()
{
  if (out[level] == remaining_jobs[level][remaining_jobs[level].size() - 1]) 
    return false;
  else
    {
      current_job[level]++;
      out[level] = remaining_jobs[level][current_job[level]];
      out.ComputeTimes();
    }
  return true;
}

bool FSSP_Backtracking::Feasible()
{
    return true;
}

unsigned FSSP_Backtracking::Cost()
{
  if(BacktrackingOpt::FullSolution())
    {
      out.ComputeMakespan();
      out.ComputeTotalWeightedTardiness();
      out.ComputeCost();
    }
  else
    return out.ComputeCurrentCost(level);

  return out.TotalCost();
}

bool FSSP_Backtracking::NonImprovingBranch()
{
  return Cost() >= best_cost; 
}

void FSSP_Backtracking::GoDownOneLevel()
{
  bool found = false; // = true se job giĆ  inserito
  int l;
  unsigned j;
    
  level++;
  remaining_jobs[level].clear();
  current_job[level] = 0;

  for (j = 0; j < in.Jobs(); j++)
    {
      found = false; 
      for (l = 0; l < level; l++)
        {    
          if (j == out[l])
            found = true;
        }
        
      if(found == false)
        remaining_jobs[level].push_back(j);
    }
}

void FSSP_Backtracking::GoUpOneLevel()
{
  remaining_jobs[level].clear();
  current_job[level] = 0;
  level--;
}

so please give me some hint to where correct this problem

Source: Windows Questions C++

LEAVE A COMMENT