Like Tree1Likes
  • 1 Post By Elysia

Please help , I am new in qt ~simple program

This is a discussion on Please help , I am new in qt ~simple program within the C++ Programming forums, part of the General Programming Boards category; Please help ... I am coming from Java and new in qt and c++ I am getting these errors //I ...

  1. #1
    Registered User
    Join Date
    Feb 2013
    Posts
    17

    Please help , I am new in qt ~simple program

    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


    Code:
    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


    Code:
    #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




    Code:
    #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




    Code:
    #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

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,418
    Is Solve.cpp even in your project, or compiled?
    Code:
    $ cat bar.cpp Solve.cpp Solve.h
    #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);
    }
    #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)
    {
    }
    #ifndef SOLVE_H
    #define SOLVE_H
    #include <iostream>
    using namespace std;  //!! note: very poor practice to put using namespace in header files
    
    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
    $ g++ -Wall bar.cpp Solve.cpp
    bar.cpp: In function ‘int main(int, char**)’:
    bar.cpp:8:10: warning: unused variable ‘am’ [-Wunused-variable]
    It seems fine, if you actually compile it.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,411
    Unlike Java, in C++ you don't have to use new, and shouldn't unless you absolutely have to. So:

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

    should be

    Solve am(1,1,1,1,1,1,1,1,1,1,1,1);
    stahta01 likes this.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple program, simple problem
    By KAUFMANN in forum C Programming
    Replies: 5
    Last Post: 02-16-2011, 12:16 PM
  2. simple program, simple error? HELP!
    By colonelhogan44 in forum C Programming
    Replies: 4
    Last Post: 03-21-2009, 11:21 AM
  3. Simple program...simple problem?
    By deadherorising in forum C Programming
    Replies: 2
    Last Post: 03-12-2009, 08:37 PM
  4. Simple program, not so simple problem
    By nolsen in forum C++ Programming
    Replies: 2
    Last Post: 01-18-2008, 09:28 AM
  5. Need help with simple, simple program.
    By LightsOut06 in forum C Programming
    Replies: 5
    Last Post: 09-01-2005, 08:31 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21