home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 31,484 of 33,346   
   Paul Floyd to ptyxs   
   Re: sqrt(a) with 'a' being an int   
   23 Sep 11 16:40:06   
   
   4255471e   
   From: root@127.0.0.1   
      
   On Wed, 21 Sep 2011 06:29:39 -0700 (PDT), ptyxs  wrote:   
   >   
   > Thanks to all for the interesting answers.   
   > In fact, such a program as the following (with std:: in front of   
   > sqrt) :   
   >   
   >     int a = 25;   
   >     std::cout << std::sqrt(a) << std::endl;   
   >   
   > doesn't compile (as expected), and outputs the following error   
   > message :   
   >   
   > [toto@localhost ~]$ g++  -std=c++0x  -Wall -pedantic  sqrtmy3.cpp   
   > sqrtmy3.cpp: In function ‘int main()’:   
   > sqrtmy3.cpp:8:18: error: ‘sqrt’ is not a member of ‘std’   
   > sqrtmy3.cpp:8:18: note: suggested alternative:   
   > /usr/include/bits/mathcalls.h:157:1: note:   ‘sqrt’   
      
   I'd say that your compiler or more likely standard headers are wrong.   
      
   For what it's worth I get   
      
   CC -o main x.cpp -library=stlport4   
   "x.cpp", line 8: Error: Overloading ambiguity between   
   "std::sqrt(double)" and "std::sqrt(long double)".   
   1 Error(s) detected.   
      
   with Oracle Studio 12.3 beta.   
      
   A+   
   Paul   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca