How to amend this code?

Discussion in 'C++' started by Rex Chou, Apr 2, 2006.

  1. Rex Chou

    Rex Chou Guest

    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!
    Rex Chou, Apr 2, 2006
    #1
    1. Advertising

  2. * 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?
    Alf P. Steinbach, Apr 2, 2006
    #2
    1. Advertising

  3. 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.
    Joost Kraaijeveld, Apr 2, 2006
    #3
  4. 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!
    ardent_c_phil, Apr 2, 2006
    #4
  5. Rex Chou

    Jack Klein Guest

    On 2 Apr 2006 08:40:11 -0700, "ardent_c_phil" <>
    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/~ajo/docs/FAQ-acllc.html
    Jack Klein, Apr 2, 2006
    #5
  6. Rex Chou

    Fei Liu Guest

    "Rex Chou" <> wrote in message
    news:...
    > 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!
    >
    Fei Liu, Apr 5, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ron
    Replies:
    1
    Views:
    2,693
    Showjumper
    Jun 24, 2003
  2. Ian
    Replies:
    0
    Views:
    1,376
  3. Ben Miller [msft]

    Re: Code Behind vs. no code behind: error

    Ben Miller [msft], Jun 27, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    565
    Alphonse Giambrone
    Jun 28, 2003
  4. =?Utf-8?B?Q2FybG8gTWFyY2hlc29uaQ==?=

    Fire Code behind code AND Javascript code associated to a Button Click Event

    =?Utf-8?B?Q2FybG8gTWFyY2hlc29uaQ==?=, Feb 10, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    21,175
    =?Utf-8?B?Q2FybG8gTWFyY2hlc29uaQ==?=
    Feb 11, 2004
  5. keithb
    Replies:
    1
    Views:
    888
    Bruce Barker
    Mar 29, 2006
Loading...

Share This Page