'Undefined reference to class method' inc C++/QT -


hi have problem class objects , maybe can solve it. code:

plugin.h:

    class demandplugin  {      public:         qstring sendtodb(qsqldatabase &db, qstring &cache, qstring function);         qsqldatabase db;         demandplugin();         virtual ~demandplugin();  }; 

plugin.cpp:

 demandplugin::demandplugin()  {      if (!db.open())      {          globallog::log("sqlsource", "error: cannot connect db!");      }       this->selectedpath = qstring::null;   /* here things don't want show you, sorry ;) */ }   qstring demandplugin::sendtodb(qsqldatabase &db, qstring &cache, qstring function)    {      qsqlquery query(function,db);      query.next();      cache = query.value(0).tostring();      return cache;    }  demandplugin::~demandplugin() { } 

these 2 files above propably ok, located in 1 location in project (project/subs/demands/plugin.h , project/subs/demands/plugin.cpp). problem third one. file, called task.cpp in loaction project/api/capi/task.cpp.

i want use class object defined in "plugin" returns error: 'undefined reference 'demandplugin::sendtodb(qsqldatabase&, qstring&, qstring)'.

#include "../../subs/demands/plugin.h"  demandplugin *demand_plugin = new demandplugin();  double task::gettotalcost() {      //return (costcoef * cost + basecost) * waitcoef;  // //     qstring hostname = globalconfig::getvalue("dbcredentials.ini", "database/host").tostring();     qstring database = globalconfig::getvalue("dbcredentials.ini", "database/db_name").tostring();     qstring username = globalconfig::getvalue("dbcredentials.ini", "database/user").tostring();     qstring password = globalconfig::getvalue("dbcredentials.ini", "database/password").tostring();       qstring connectionname = qstring::number((int)this, 16);     qsqldatabase db;     db = qsqldatabase::adddatabase("qpsql", connectionname);     db.sethostname(hostname);     db.setdatabasename(database);     db.setusername(username);     db.setpassword(password);      qstring worker_name = globalconfig::getvalue("cloud.ini", "name").tostring();     qstring tbname;     qstring value;     double infinity = std::numeric_limits<float>::infinity();     qlist <qstring> tagnamevalue_tag;      double new_cost;           if(worker_name.contains("luke") ==true)             {                  qstring line1 = "select tags test suite_id = '"+ getparam("subs_test_id") +"'";                  tagnamevalue_tag = demand_plugin->sendtodb(db, value, line1).split(" ");                  qstring part_of_query;                 (int q=0; q<tagnamevalue_tag.count(); q++)                 {                     part_of_query = part_of_query +"and tags '%"+tagnamevalue_tag[q]+"%'";                 }                  qstring line3 = "update test set selected = 'yes' id = (select id testbays name '%luke%' , selected='no'"+part_of_query+" order id limit 1) returning name;";                  tbname = demand_plugin->sendtodb(db, value, line3);                  if(tbname == null)                 {                     new_cost = infinity;                 }                 else                 {                     new_cost = (costcoef * cost + basecost) * waitcoef;                 }             }     return new_cost; } 


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -