Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pow() trouble in MS visual C++.NET

Status
Not open for further replies.

spamdogg

Programmer
Feb 1, 2005
3
0
0
US
I am new to C++ and havn't used C in quite a while. I am trying to complie the code listed below. When I compile the code I get a compiler error that says "C2666: 7 overloads have similar conversions" I am using MS Visual C++.NET. If I click on the error it takes me to the pow() function in the do loop. I have tried including math.h and complex.h but neither helped. Can anyone tell me what is wrong here?

Thanks
Scott

#include <iostream>
#include <cmath>
#include <complex>
#include <iomanip>
using namespace std;
void main()
{
double conversion_factor=0.00194032;
double mult_factor=0.2222222;
double rho=1.225;
double converted_rho=0;
cout<<"rho kg/m^3"<<"\t"<<"rho slug/ft^3"<<endl;
cout<<"----------"<<"\t"<<"-------------"<<endl;
do
{
double i=0;
converted_rho=rho*conversion_factor;
cout<<setprecision(4)<<rho<<"\t\t"<<converted_rho<<endl;
i+=mult_factor;
complex <double> lognum=pow(10,-i);
rho*=lognum;
}while (rho>=0.01225);
}
 
I posted the wrong code. Below is the correct version. This has the same problem.

#include <iostream>
#include <cmath>
#include <complex>
#include <iomanip>
using namespace std;
void main()
{
//assigning constants and initializing
double conversion_factor=0.00194032;
double mult_factor=0.2222222;
double rho=1.225;
double converted_rho=0;
//printing header
cout<<"rho kg/m^3"<<"\t"<<"rho slug/ft^3"<<endl;
cout<<"----------"<<"\t"<<"-------------"<<endl;
//calculating the table conversions
do
{
double i=0;
converted_rho=rho*conversion_factor;
cout<<setprecision(4)<<rho<<"\t\t"<<converted_rho<<endl;
i+=mult_factor;
rho*=pow(10,-i);
}while (rho>=0.01225);
}
 
Please use [ignore]
Code:
[/ignore]
tags when posting code.

> void main()
main returns an int in C++
void is at best a compiler specific extension, and at worst undefined behaviour.

> rho*=pow(10,-i);
It's complaining about overloads. It's looking for pow(int,double).
Try
Code:
rho*=pow(10.0,-i);

--
 
Thanks for the info. It worked! I will remember to use the cod tags next time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top