473,463 Members | 1,496 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to amend this code?

It is very simple, but the G++ compiler say it's wrong. I don't know
why.

#include<iostream>
#include<cmath>
using namespace std;

int main()
{
cout << pow(2,3) << endl;
return 0;
}

The G++ display: call of overloaded 'pow(int, int)' is ambiguous.

Thank you!

Apr 2 '06 #1
5 3285
* Rex Chou:
It is very simple, but the G++ compiler say it's wrong. I don't know
why.

#include<iostream>
#include<cmath>
using namespace std;

int main()
{
cout << pow(2,3) << endl;
return 0;
}

The G++ display: call of overloaded 'pow(int, int)' is ambiguous.

Thank you!


Please post complete error messages so we don't have to guess.

Happily in this case it's simple, but please post complete error
messages so we don't have to guess.

Simply change 2 to 2.0, thus ambiguating the call, and please post
complete error messages so we don't have to guess.

Hth.,

- Alf

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Apr 2 '06 #2
Rex Chou wrote:
It is very simple, but the G++ compiler say it's wrong. I don't know
why.

#include<iostream>
#include<cmath>
using namespace std;

int main()
{
cout << pow(2,3) << endl;
return 0;
}

The G++ display: call of overloaded 'pow(int, int)' is ambiguous.


It actually says:

test.cpp: In function 'int main()':
test.cpp:7: error: call of overloaded 'pow(int, int)' is ambiguous
/usr/include/bits/mathcalls.h:154: note: candidates are: double
pow(double, double)
/usr/lib/gcc/x86_64-linux-gnu/4.0.3/../../../../include/c++/4.0.3/cmath:360:
note: long double std::pow(long double, int)
/usr/lib/gcc/x86_64-linux-gnu/4.0.3/../../../../include/c++/4.0.3/cmath:356:
note: float std::pow(float, int)
/usr/lib/gcc/x86_64-linux-gnu/4.0.3/../../../../include/c++/4.0.3/cmath:352:
note: double std::pow(double, int)
/usr/lib/gcc/x86_64-linux-gnu/4.0.3/../../../../include/c++/4.0.3/cmath:348:
note: long double std::pow(long double, long double)
/usr/lib/gcc/x86_64-linux-gnu/4.0.3/../../../../include/c++/4.0.3/cmath:344:
note: float std::pow(float, float)
Just choose on of the appropriate functions ant tell the compiler by
casting or typing appropriate dot.zero's ('.0') which function to choose.
Apr 2 '06 #3
Hi!
rex
pow() is not suported by c++ on linux

regards
phil

Rex Chou wrote:
It is very simple, but the G++ compiler say it's wrong. I don't know
why.

#include<iostream.h>
//#include<cmath.h>
using namespace std;

int main()
{
cout << pow(2,3) << endl;
return 0;
}

The G++ display: call of overloaded 'pow(int, int)' is ambiguous.

Thank you!


Apr 2 '06 #4
On 2 Apr 2006 08:40:11 -0700, "ardent_c_phil" <ar**********@yahoo.com>
wrote in comp.lang.c++:

Don't top post. Your input belongs after or interspersed with
material in the original you are responding to.
Hi!
rex
pow() is not suported by c++ on linux


Don't post here at all if you don't know what you are talking about.
You are completely wrong.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Apr 2 '06 #5

"Rex Chou" <re*****@gmail.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...
It is very simple, but the G++ compiler say it's wrong. I don't know
why.

#include<iostream>
#include<cmath>
using namespace std;

int main()
{
cout << pow(2,3) << endl; try cout << pow(2., 3.) << endl; return 0;
}

The G++ display: call of overloaded 'pow(int, int)' is ambiguous.

Thank you!

Apr 5 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

51
by: Mudge | last post by:
Please, someone, tell me why OO in PHP is better than procedural.
9
by: bigoxygen | last post by:
Hi. I'm using a 3 tier FrontController Design for my web application right now. The problem is that I'm finding to have to duplicate a lot of code for similar functions; for example, listing...
4
by: jason | last post by:
Hello. Newbie on SQL and suffering through this. I have two tables created as such: drop table table1; go drop table table2; go
16
by: Dario de Judicibus | last post by:
I'm getting crazy. Look at this code: #include <string.h> #include <stdio.h> #include <iostream.h> using namespace std ; char ini_code = {0xFF, 0xFE} ; char line_sep = {0x20, 0x28} ;
109
by: Andrew Thompson | last post by:
It seems most people get there JS off web sites, which is entirely logical. But it is also a great pity since most of that code is of such poor quality. I was looking through the JS FAQ for any...
5
by: ED | last post by:
I currently have vba code that ranks employees based on their average job time ordered by their region, zone, and job code. I currently have vba code that will cycle through a query and ranks each...
0
by: Namratha Shah \(Nasha\) | last post by:
Hey Guys, Today we are going to look at Code Access Security. Code access security is a feature of .NET that manages code depending on its trust level. If the CLS trusts the code enough to...
5
by: Benson Wong | last post by:
I want to write a tailor-made function or class to amend textedit controls, so that their properties are consistent or changed by some rules. My idea is as follows: TailorMadeRoutine(TextBox1) ...
1
by: GPD | last post by:
I thought I had done this before but cant see a way how. Am sure I once opened a table and amended some data. Anyone know if possible or how, any permissions needed from 10G EM. PS I know...
3
by: bharadwajrv | last post by:
Hi, i need to amend the value stored in the element in XSLT and this needs to be carried out with in a <template> code.. Please can you help me how to do this? in the below code, in...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.