Bonjour,
j'ai à créer un code pour verifier si deux points a et b par exemple coincide.
coincide est une fonction membre de ma classe Point.Et je dois passer mon objet par pointeur sur cette methode...le code est le voila:
Et lors de la compilation voila les erreurs que j'obtiens:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 #include<iostream.h> class Point{ private: int x,y; public: Point(int abs=0,int ord=2) {x=abs; y=ord; }//constructeur int coincide(Point*); }; int Point::coincide(Point *pt) { pt=new Point; if((pt->x==x)&&(pt->y==y)) return 1; else return 0; } int main() { int test1,test2; Point a; Point b(1); test1=a->coincide(b); test2=b->coincide(a); cout<<"a et b:"<<test1<<"ou"<<test2<<endl; return 0; }
Compiling...
coincide.cpp
C:\Documents and Settings\salma\Bureau\Tp C++\coincide.cpp(26) : error C2819: type 'Point' does not have an overloaded member 'operator ->'
C:\Documents and Settings\salma\Bureau\Tp C++\coincide.cpp(2) : see declaration of 'Point'
C:\Documents and Settings\salma\Bureau\Tp C++\coincide.cpp(26) : error C2227: left of '->coincide' must point to class/struct/union
C:\Documents and Settings\salma\Bureau\Tp C++\coincide.cpp(27) : error C2819: type 'Point' does not have an overloaded member 'operator ->'
C:\Documents and Settings\salma\Bureau\Tp C++\coincide.cpp(2) : see declaration of 'Point'
C:\Documents and Settings\salma\Bureau\Tp C++\coincide.cpp(27) : error C2227: left of '->coincide' must point to class/struct/union
Error executing cl.exe.
j'attend vos commentaires!
Merci,
cordialement!![]()
Partager