Bonjour à tous,
J'ai une méthode qui calcule la distance entre 2points. le but étant dans un triangle de type isocèle d'arrivé à calculer la base, un des cotés qui est isocèle et ensuite de les diviser l'un par l'autre.
Seul problème après compilation la compilateur m'affiche celà :
appel du constructeur simple : 0035A3D0 0 0
appel du constructeur simple : 0035A480 0 2
appel du constructeur simple : 0035A4B8 1 1
Ces points forment un triangle
isocèle en c
La longueur de la base est : 1.#INF <-----------------------------------------------------ERREUR ICI JE PENSE
Appuyez sur une touche pour continuer..
Mon code est celui là :
CONSTRUCTEUR CLASSE POINT ET CES METHODES :
// Point.cpp: implementation de la classe Point
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Point.h"
#include "Math.h"
#include <iostream>
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
using namespace std;
Point::Point(float x, float y) {
this->x = x;
this->y = y;
cout << "appel du constructeur simple : " << this << " "<< x <<" "<< y <<endl;
}
/*Point::Point(const Point & p){
x = p.x;
y = p.y;
cout << "appel du constructeur par recopie" << this << " "<< x <<" "<< y <<endl;
}*/
void Point::Affiche()
{
cout<<"Abscisse :"<< x <<"Ordonnée :"<< y <<endl;
}
Point::~Point()
{
//cout<<"Appel du destructeur de Point"<<endl;
}
float Point::getx(){
return(x);
}
void Point::setx(float x) {
this->x = x;
}
float Point::gety(){
return(y);
}
void Point::sety(float y) {
this->y = y;
}
float Point::Calclong(Point b){
float res;
res = abs((b.y - this->y)/(b.x - this->x));
return(res);
}
bool Point::Compoint(Point b){
bool test;
test =0;
if((b.y == this->y) && (b.x == this->x))
{
test=1;
}
else{
test = 0;
}
return(test);
}
CONSTRUCTEUR DE TRIISO ET CES METHODES :
// TriIso.cpp: implementation of the TriIso class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "TriIso.h"
#include "Point.h"
#include <iostream>
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
using namespace std;
TriIso::TriIso(Point a,Point b,Point c)
{
if ((a.Compoint(b)==0)&&(b.Compoint(c)==0)&&(c.Compoint(a)==0)) //si des point tous != alors..
{ //...c'est un triangle simple
cout << "Ces points forment un triangle "<<endl;
if ((a.Calclong(b))==(b.Calclong(c))){//si ab=bc -> sommet=b
sommet = 'b';
cout << "isoc\x8Ale en b" << endl;
}
else if ((b.Calclong(c))==(c.Calclong(a))){//si bc=ca -> sommet=c
sommet = 'c';
cout << "isoc\x8Ale en c" << endl;
}
else if ((c.Calclong(a))==(a.Calclong(b))){//si ca=ab -> sommet=a
sommet = 'a';
cout << "isoc\x8Ale en a" << endl;
}
else{
cout << "non isoc\x8Ale" << endl;
}
}
else{
cout<<"Ce n'est pas un triangle"<<endl;
}
}
char TriIso::getsommet(){
return(sommet);
}
void TriIso::setsommet(char sommet) {
this->sommet = sommet;
}
TriIso::~TriIso()
{
}
TriIso::TriIso(){}
Voilà si quelqu'un à une idée d'ou peut venir mon erreur

cordialement, ichigoZ710
