Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8986787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:38:03+00:00 2026-06-15T21:38:03+00:00

Possible Duplicate: C++ compiler error: ambiguous call to overloaded function just copied some code

  • 0

Possible Duplicate:
C++ compiler error: ambiguous call to overloaded function

just copied some code from a pdf into both C++builder XE2 and visual studio express 2012. both both compilers give error codes about ambiquity. I just started so i don’t really know what to do. Maybe my textbook(pdf) is old and obsolete now? it’s called “Learn c++ in 14 days”. Well anyways here is the copied code.

#include <iostream.h>
#include <conio.h>
#include <math.h>
#include <stdio.h>
#pragma hdrstop
void getSqrRoot(char* buff, int x);
int main(int argc, char** argv)
{
int x;
char buff[30];
cout << “Enter a number: “;
cin >> x;
getSqrRoot(buff, x);
cout << buff;
getch();
}
void getSqrRoot(char* buff, int x)
{
sprintf(buff, “The sqaure root is: %f”, sqrt(x));
}

the errorcode i got in c++builder is:

[BCC32 Error] SquareRoot.cpp(19): E2015 Ambiguity between ‘std::sqrt(float) at c:\program files (x86)\embarcadero\rad studio\9.0\include\windows\crtl\math.h:266’ and ‘std::sqrt(long double) at c:\program files (x86)\embarcadero\rad studio\9.0\include\windows\crtl\math.h:302’
Full parser context
SquareRoot.cpp(18): parsing: void getSqrRoot(char *,int)

On a side note, the quotation marks in my pdf manual are different characters than the normal ” which i type. these “ are also not compatible with the compiler. maybe anybody knows a fix for this as well? thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T21:38:04+00:00Added an answer on June 15, 2026 at 9:38 pm

    Change your code like that:

    void getSqrRoot(char* buff, int x)
    {
     sprintf(buff, “The sqaure root is: %f”, sqrt((float)x));
    }
    

    Because square root is overloaded function compiler has no opportunity to implicit conversion from int x value to float or double value, you need to do it directly.

    Compiler: see sqrt(int) -> what to choose? sqrt(float)/sqrt(double) ?
    Compiler: see sqrt((float)int) -> sqrt(float), ok!
    Compeler: see sqrt((double)int) -> sqrt(double), ok!
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Convert some code from C++ to C I've got some code that
Possible Duplicate: Java isEmpty() undefined for String? I copied my code from one java
Possible Duplicate: Type result with conditional operator in C# Basically I have some code
Possible Duplicate: Google Closure Compiler parse error: invalid property id for css({float:&#39;left&#39;}) I tried
Possible Duplicate: Why can you return from a non-void function without returning a value
Possible Duplicate: C++ source in unicode I just discovered this line of code in
Possible Duplicate: ios::nocreate error while compiling a C++ code i have been working on
Possible Duplicate: C# switch variable initialization: Why does this code NOT cause a compiler
Possible Duplicate: Why can you return from a non-void function without returning a value
Possible Duplicate: const and global This code will produce error in c++ // Foo.cpp

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.