std::cout

de Chalendar Gael de-chalendarg@zoe.cea.fr
Wed Dec 4 08:56:00 GMT 2002


The library to use is <cmath> which is the standard replacement of
<math.h>.
The same is true for other C libraries : <cstdio> for <stdio.h>, etc.

Gael
On mer, 2002-12-04 at 16:48, Eduardo Osorio Armenta wrote:
> okey !
> 
> i tried to compile this program
> with 
> 
> g++ exponencial.cpp -o exponencial -g -O2 -Wall -lm
> 
> ---------------------------------------------------
> #include <iostream>
> #include <sstream>
> #include <math>
> #include <string>
> 
> using namespace std;
> 
> int
> main (int argc, char **argv)
> {
>   int i;
>   string szTexto ("hola con string en g++");
> 
>   cout << szTexto << endl;
> 
>   for (i = 0; i < 32; i++)
>     {
>       cout << "2^" << dec << i << " = 0x" << hex <<
> (int) pow (2, i) << endl;
>     }
>   return 0;
> }
> ----------------------------------------------------
> but the answer
> 
> $ make exponencial
> g++ exponencial.cpp -o exponencial -g -O2 -Wall
> exponencial.cpp:4:16: math: No such file or directory
> exponencial.cpp: In function `int main(int, char**)':
> exponencial.cpp:19: call of overloaded `pow(int,
> int&)' is ambiguous
> /usr/include/math.h:60: candidates are: double
> pow(double, double)
> /usr/include/c++/3.2/cmath:427:                 long
> double std::pow(long
>    double, int)
> /usr/include/c++/3.2/cmath:423:                 float
> std::pow(float, int)
> /usr/include/c++/3.2/cmath:419:                 double
> std::pow(double, int)
> /usr/include/c++/3.2/cmath:414:                 long
> double std::pow(long
>    double, long double)
> /usr/include/c++/3.2/cmath:401:                 float
> std::pow(float, float)
> make: *** [exponencial] Error 1
> 
> 
> what it's wrong with <math> or maybe <math.h>
> 
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com




More information about the Gcc-help mailing list