LNK2019

Why i keep getting this error.
1>Programming6.3.obj : error LNK2019: unresolved external symbol "void __cdecl solveEquation(double &,double &)" (?solveEquation@@YAXAAN0@Z) referenced in function _main
Whats wrong with my code?


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

void solveEquation(double &,double &);



int main ()
{	
	double k;
	double j;
	solveEquation(k,j);
	cout << k << j;

}



void solveEquation(double a, double b, double c, double d, double e, double f, double &x, double &y)
{

	cout << "Enter a,b,c,d,e,f: ";

	cin >> a,b,c,d,e,f;
x = (e*d - b* f)/(a*d - b*c);
y = (a*f - e* c)/(a*d-b*c);
}

The message is clear enough. The linker can not find the definition of function

void solveEquation(double &,double &);

You declared such function, call it in main but did not define it.
Last edited on
As an aside, your function is nonsensical. You call the function with values of a, b, c, d, e, f, x and y... and then try to make the user input a, b, c, d, e, f anyway, overwriting the ones you passed in (except that you're using cin >> wrongly to do this and making a complete mess of it).

You need to learn:

1) Functions.
2) How to use cin.
Last edited on
can u show me the correct way?
1
2
3
4
5
6
7
8
9
10
void solveEquation( double &x, double &y )
{
	double a, b, c, d, e, f;

	cout << "Enter a,b,c,d,e,f: ";

	cin >> a >> b >> c >> d >> e >> f;
	x = (e*d - b* f)/(a*d - b*c);
	y = (a*f - e* c)/(a*d-b*c);
}

1
2
3
4
5
6
7
8
9
void solveEquation(double &x, double &y)
{
    double a, b, c, d, e, f; // "local variables"

    cout << "Enter a, b, c, d, e, f: ";
    cin >> a >> b >> c >> d >> e >> f;
    x = (e*d - b* f)/(a*d - b*c);
    y = (a*f - e* c)/(a*d-b*c);
}

Damn you, vlad! Ha ha.
But my question is like this:

http://imageshack.us/a/img341/555/questionx.jpg
Then don't try to call the function like this:
solveEquation(k,j);

Call it like this:
solveEquation(a,b,c,d,e,f,x,y, isSolvable);

Do you understand that if you write the function to take in 9 parameters, as you have done and the question demands, when you call it you must pass in 9 parameters?
Then i need to declare from a to f, x and y in my main func again?
Declare and read them too, in main().
Then your solveEquation() will be plain "muscle", with no cin and no cout.
Topic archived. No new replies allowed.