Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Exercice 47 coordonnées tridimensionnelles 110
- #include <iostream>
- #include <string>
- using namespace std;
- //----------------------------------------------------------------------
- class Point3D{
- public:
- Point3D(float x=1,float y=1,float z=1);
- ostream& affiche (ostream& stream);
- bool compare(Point3D const &p);
- private :
- float x,y,z;
- };
- //----------------------------------------------------------------------
- //----------------------------------------------------------------------
- Point3D::Point3D(float x,float y,float z):x(x),y(y),z(x){}
- ostream& Point3D::affiche (ostream& stream){
- stream <<"( "<<x<<" , "<<y<<" , "<<z<<" )"<<endl;
- return stream;
- }
- bool Point3D::compare(Point3D const &p){
- if (p.x==x && p.y==y && p.z==z){return true;}
- return false;
- }
- ostream& operator <<(ostream& os ,Point3D p){
- return p.affiche(os);
- }
- //----------------------------------------------------------------------
- int main(){
- Point3D A, B(2,1,1), C(1,1,1); //Trois points
- cout<<A<<B<<C<<endl;//Affiche les trois points
- cout<<A.compare(B)<<endl;//Compare A avec B
- cout<<A.compare(C)<<endl;//et A avec C
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement