Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ trouble with extern - undefined reference
    primarykey
    data
    text
    <p><strong>main.cpp:</strong></p> <pre><code>bool lgstatus; User currentUser; //... int main(){ //... } </code></pre> <p><strong>loginwindow.cpp:</strong></p> <pre><code>void LoginWindow::on_cmdCreate_clicked() { extern bool lgstatus; extern User currentUser; //... currentUser.setMail(ui-&gt;txtAccountMail-&gt;text().toStdString()); currentUser.setName(ui-&gt;txtAccountName-&gt;text().toStdString()); currentUser.setPassword(ui-&gt;txtAccountPassword-&gt;text().toStdString()); //... lgstatus = true; } </code></pre> <p>My class <code>User</code> has 3 functions. Each of them takes a string as argument. I don't know whats wrong. The compiler doesn't complain if I change <code>lgstatus</code> but my <code>currenUser</code>. </p> <p>Class :</p> <pre><code>class User { public: User(); User(const std::string &amp;name, const std::string &amp;password); User(const std::string &amp;name, const std::string &amp;password, const std::string &amp;mail); void setName(const std::string &amp;name); void setMail(const std::string &amp;mail); void setPassword(const std::string &amp;password); private: std::string user_name; std::string user_password; std::string user_mail; }; </code></pre> <p>The "set" functions simply pass their argument to the user_name etc. I don't think it would be necessary to show them as well.</p> <p>Errors : </p> <ul> <li><p>undefined reference to 'User::setMail(std::string const&amp;)' </p></li> <li><p>undefined reference to 'User::setName(std::string const&amp;)'</p></li> <li><p>undefined reference to `User::setPassword(std::string const&amp;)'</p></li> </ul> <p>What did I do wrong?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload