C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

problème avec abs

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (French)
View previous topic :: View next topic  
Author Message
fanny & michou
Guest





PostPosted: Fri Sep 10, 2004 9:17 pm    Post subject: problème avec abs Reply with quote



Bonjour,

Mon programme compile correctement a mon travail mais a des
erreurs chez moi...
Les versions de g++ sont :
a mon travail g++ (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-42)
chez moi g++ (GCC) 3.4.1 (Mandrakelinux (Alpha 3.4.1-3mdk)

L'erreur de compilation est la suivante :
Graph.cpp:467: error: call of overloaded `abs(double)' is ambiguous
/usr/include/stdlib.h:748: note: candidates are: int abs(int)

Cette erreur n'apparait pas a mon travail...
Quelqu'un a-t-il une explication?
Est-ce que les résultats fournis par abs(double) sont alors erronés
a mon travail?

Merci pour votre aide...

Fanny
Back to top
Fabien LE LEZ
Guest





PostPosted: Fri Sep 10, 2004 9:21 pm    Post subject: Re: problème avec abs Reply with quote



On Fri, 10 Sep 2004 23:17:19 +0200, fanny & michou
<fanny.michou (AT) free (DOT) fr>:

Quote:
Graph.cpp:467: error: call of overloaded `abs(double)' is ambiguous

Si je ne m'abuse, "int abs(int)" est déclaré dans stdlib.h et "double
abs (double)" dans math.h. Ça vient peut-être de là...


--
;-)

Back to top
fanny & michou
Guest





PostPosted: Fri Sep 10, 2004 9:33 pm    Post subject: Re: problème avec abs Reply with quote



Fabien LE LEZ a écrit :
Quote:
On Fri, 10 Sep 2004 23:17:19 +0200, fanny & michou
[email]fanny.michou (AT) free (DOT) fr[/email]>:


Graph.cpp:467: error: call of overloaded `abs(double)' is ambiguous


Si je ne m'abuse, "int abs(int)" est déclaré dans stdlib.h et "double
abs (double)" dans math.h. Ça vient peut-être de là...


J'ai pourtant #include <math.h> dans mon fichier...


Back to top
Gabriel Dos Reis
Guest





PostPosted: Sat Sep 11, 2004 2:50 am    Post subject: Re: problème avec abs Reply with quote

fanny & michou <fanny.michou (AT) free (DOT) fr> writes:

Quote:
Bonjour,

Mon programme compile correctement a mon travail mais a des
erreurs chez moi...
Les versions de g++ sont :
a mon travail g++ (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-42)
chez moi g++ (GCC) 3.4.1 (Mandrakelinux (Alpha 3.4.1-3mdk)

L'erreur de compilation est la suivante :
Graph.cpp:467: error: call of overloaded `abs(double)' is ambiguous
/usr/include/stdlib.h:748: note: candidates are: int abs(int)

Cette erreur n'apparait pas a mon travail...
Quelqu'un a-t-il une explication?

CEci devrait être une FAQ.

#include <cmath>

-- Gaby

Back to top
Gabriel Dos Reis
Guest





PostPosted: Sat Sep 11, 2004 2:52 am    Post subject: Re: problème avec abs Reply with quote

fanny & michou <fanny.michou (AT) free (DOT) fr> writes:

Quote:
Fabien LE LEZ a écrit :
On Fri, 10 Sep 2004 23:17:19 +0200, fanny & michou
[email]fanny.michou (AT) free (DOT) fr[/email]>:

Graph.cpp:467: error: call of overloaded `abs(double)' is ambiguous
Si je ne m'abuse, "int abs(int)" est déclaré dans stdlib.h et "double
abs (double)" dans math.h. Ça vient peut-être de là...

J'ai pourtant #include <math.h> dans mon fichier...

Il te faut

#include <cmath>

-- Gaby

Back to top
Bertrand Lenoir-Welter
Guest





PostPosted: Sat Sep 11, 2004 9:26 am    Post subject: Re: problème avec abs Reply with quote

Quote:
Si je ne m'abuse, "int abs(int)" est déclaré dans stdlib.h et "double
abs (double)" dans math.h. Ça vient peut-être de là...

Il me semble que tu t'abuses. Le help de Borland sur <math.h> propose
bien "abs", mais il renvoie à <stdlib.h> sur de l'entier. Pour du
flottant double ou long double, c'est "fabs" ou "fabsl".

Back to top
Gabriel Dos Reis
Guest





PostPosted: Sat Sep 11, 2004 2:36 pm    Post subject: Re: problème avec abs Reply with quote

Bertrand Lenoir-Welter <bertrand.2004 (AT) galaad (DOT) net> writes:

Quote:
Si je ne m'abuse, "int abs(int)" est déclaré dans stdlib.h et "double
abs (double)" dans math.h. Ça vient peut-être de là...

Il me semble que tu t'abuses. Le help de Borland sur <math.h> propose
bien "abs", mais il renvoie à <stdlib.h> sur de l'entier. Pour du
flottant double ou long double, c'est "fabs" ou "fabsl".

Pour du flottant double, float ou long double, C++ définit abs() dans
<cmath> et <math.h>. Mais vu ce qui se passe avec beaucoup
d'implémentations, on a plus de chance d'avoir abs(double) dans
<cmath> que dans <math.h>.

De toute façon, c'est de l'hystérie d'avoir surcharger abs() de cette
façon.

-- Gaby

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (French) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.