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
@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
@ -
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!
-
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#.