Function Error

Error : Messages

error LNK2019: unresolved external symbol "double __cdecl calc_power(double,double,double,double &,double &,double &)" (?calc_power@@YANNNNAAN00@Z) referenced in function _main



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
30
31
32
33
34
35
36
  #include<iostream>
#include<cmath>
using namespace std;
double calc_power(double,double, double, double&, double&, double&);
int main()
{
	double volt,res,react,realpow,reactpow,appapower;
	cout<<"Enter voltage = ";
	cin>>volt;
	cout<<"Enter resistance = ";
	cin>>res;
	cout<<"Enter reactamce = ";
	cin>>react;
	calc_power(volt,res,react,realpow,reactpow,appapower);
	cout<<"The apparent power is " << appapower << endl;
	cout<<"The real power is "<<realpow<<endl;
	cout<<"The reactive power is " <<reactpow<<endl;
}

double calc_pow(double volt, double res, double react, double& realpow, double& reactpow, double& appapower)
{
	double v = pow(volt,2);
	double r = pow(res,2);
	double x = pow(react,2);
	double realp = pow(realpow,2);
	double s = pow(appapower,2);
	double c1 = - (res) / (r + x);
	double c2 = res / ( r + x );
    appapower = v * c1 ;
	realpow = v * c2 ;
	reactpow = sqrt( realp + s );

	return realpow;
	return reactpow;
	return appapower;
}
Last edited on
At line 14 you call a function named calc_power()
However, the program doesn't have a function with that name.

It does instead have a function with a similar but different name: calc_pow()

Note: sometimes a similar error message arises when the parameter list doesn't match.

By the way, the return statement at line 33 exits from the function. The following two lines will never be executed.

Probably the return type of the function should be void and get rid of all three return statements.

At lines 25, 26
25
26
	double realp = pow(realpow,2);
	double s = pow(appapower,2);
Both realpow and appapower are being used in a calculation but they contain garbage values. They were not initialised when declared at line 7 and have not been assigned any value before being used.
Last edited on
@chervil thanks for the reply. i fixed it already according to what you tell me. thank you ! :)
Topic archived. No new replies allowed.