Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Please help , I am new in qt ~simple program
QtWS25 Last Chance

Please help , I am new in qt ~simple program

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    amir734jj
    wrote on last edited by
    #1

    Please help ...
    I am coming from Java and new in qt and c++
    I am getting these errors

    //I skipped to copy those parts of my code in which compiles properly

    @main.obj:-1: error: LNK2019: unresolved external symbol "public: __cdecl Solve::Solve(double,double,double,double,double,double,double,double,double,double,double,double)" (??0Solve@@QEAA@NNNNNNNNNNNN@Z) referenced in function main@

    @debug\Calculate.exe:-1: error: LNK1120: 1 unresolved externals@

    @#include <iostream>
    #include "Solve.h"
    #include <QDebug>

    using namespace std;

    int main(int argc, char *argv[])
    {

    Solve *am =new Solve(1,1,1,1,1,1,1,1,1,1,1,1);
    }@

    solve.cpp

    @
    #include <iostream>
    #include "Solve.h"

    Solve::Solve(double x1,double x2,double x3,double x4,double x5,double x6,double x7,double x8,double x9,double x10,double x11,double x12)
    {
    Solve::SetNums( x1=0, x2=0, x3=0, x4=0, x5=0, x6=0, x7=0, x8=0, x9=0, x10=0, x11=0, x12=0);
    }

    void Solve::SetNums(double x1,double x2,double x3,double x4,double x5,double x6,double x7,double x8,double x9,double x10,double x11,double x12)
    {

    }@

    solve.h

    @
    #ifndef SOLVE_H
    #define SOLVE_H

    #include <iostream>

    using namespace std;

    class Solve {

    public:
    
        Solve (double x1,double x2,double x3,double x4,double x5,double x6,double x7,double x8,double x9,double x10,double x11,double x12);
    
    
        void SetNums(double x1,double x2,double x3,double x4,double x5,double x6,double x7,double x8,double x9,double x10,double x11,double x12);
    

    };

    #endif
    @

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goblincoding
      wrote on last edited by
      #2

      Hi Amir,

      I suggest you start here:

      "www.learncpp.com":http://www.learncpp.com

      It's a good entry point to C++ IMHO. Pay close attention to constructors and member initialisation (and initialisation lists).

      Good luck!

      http://www.goblincoding.com

      1 Reply Last reply
      0
      • Chris KawaC Offline
        Chris KawaC Offline
        Chris Kawa
        Lifetime Qt Champion
        wrote on last edited by
        #3

        The code you posted actually compiles, so there's gotta be something wrong in the part that you cut out. Judging from the error message the construdtor definition is missing so check your original includes, number of params (12 args for a a constructor is a horrible idea), any typos in the names etc.

        Btw. this
        @
        Solve::SetNums( x1=0, x2=0, x3=0, x4=0, x5=0, x6=0, x7=0, x8=0, x9=0, x10=0, x11=0, x12=0);
        @
        looks like you tried to use a named parameters syntax known from C# (although you said you come from Java world)? Is that what it was suppose to be? If yes then there's no such thing in C++. What you did here is actually something completely different, although in this particular example has the same result. the x1=0 is actually an assignment, so you are overwriting the value of the Solve::Solve x1 parameter. The result of that asignment is the assigned value and it is passed to the Solve::setNums x1 param. It is not the same as giving a named parameter a value in C#.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved