what the problem had errored??


If I refect the line of number 18, 44, the code'll run good. I try to think but I haven't found the false!! You concertrate to line (18, 44). Please check it for me! thank you very much...
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
class Toado2D
{
      private:
         int x;
         int y;
         Toado2D *next;
      public:
      
         Toado2D()
         {
            x = 0;
            y = 0;
            next = NULL;
         }  
         void Laynext(Toado2D *M);
         int operator<=(Toado2D *M);
         int operator=(Toado2D *M);
         int operator>(Toado2D *M);
         friend istream &operator>>(istream &s, Toado2D *M);
         friend ostream &operator<<(ostream &s, Toado2D *M);
};
Toado2D *first, *last, *p;
void Toado2D::Laynext(Toado2D *M)
{
   this->next = p;
}
void NhapToaDo()
{
   char c;
   do
   {
      p = new Toado2D;
      cin>>p;
      if(first = NULL)
      {
         first = p;
         last = p;
      }
       else
      {
         last->Laynext(p);
         last = p;
      } 
      cout<<"Ban co muon nhap tiep khong? (c/k)";
      c = getch();
   }while(c!='k');
}

istream &operator>>(istream &s, Toado2D *M)
{
   cout<<"Nhap toa do (x, y): ";
   s>>M->x>>M->y;
   return s;
}
ostream &operator<<(ostream &s, Toado2D *M)
{
   cout<<"Toa do da nhap \n";
   s<<"("<<M->x<<","<<M->y<<")"<<endl;
   return s;
} 

int Toado2D::operator<=(Toado2D *M)
{
   if(this->x <= M->x && this->y <= M->y)
   return 1;
      else
      return 0;    
}
/*int Toado2D::operator=(Toado2D *M)
{
   if(this->x = M->x && this->y = M->y)
   return 1;
      else
      return 0; 
} */
int Toado2D::operator>(Toado2D *M)
{
   if(this->x > M->x && this->y > M->y)
   return 1;
      else
      return 0; 
}
main()
{
   first = NULL;
   last = NULL;
   NhapToaDo();  
}
Last edited on
nobody help me!! I think, you hated me because I am a foreigner, didn't you??
leave out the attitude - have only posted for 2 hours.
You're not foreign, doofus. We're the same nationality as you.

We didn't answer because your code is using non-standard C++ from 15 years ago which has been simply wrong since 1998, and because you didn't ask a question. What does your code do that you think it shouldn't do?
"What does your code do that you think it shouldn't do?"
I'm vietnamese.
I would ask that why this code appeared a false at line of 18 and 44. Which method can fix it? thank you..
I'm sorry. The attitude isn't good! But I'm vietnamese, I don't express all easily things... you should not pay attention to it.
code appeared a false at line of 18 and 44.


I don't understand what you mean. The following code is your code converted to C++. It compiles without error. You might need to get a C++ compiler in order to compile it.

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include<iostream>
#include<iomanip>
using namespace std;

class Toado2D
{
      private:
         int x;
         int y;
         Toado2D *next;
      public:
      
         Toado2D()
         {
            x = 0;
            y = 0;
            next = NULL;
         }  
         void Laynext(Toado2D *M);
         int operator<=(Toado2D *M);
         int operator=(Toado2D *M);
         int operator>(Toado2D *M);
         friend istream &operator>>(istream &s, Toado2D *M);
         friend ostream &operator<<(ostream &s, Toado2D *M);
};
Toado2D *first, *last, *p;
void Toado2D::Laynext(Toado2D *M)
{
   this->next = p;
}
void NhapToaDo()
{
   char c;
   do
   {
      p = new Toado2D;
      cin>>p;
      if(first = NULL)
      {
         first = p;
         last = p;
      }
       else
      {
         last->Laynext(p);
         last = p;
      } 
      cout<<"Ban co muon nhap tiep khong? (c/k)";
      cin >> c;
      
   }while(c!='k');
}

istream &operator>>(istream &s, Toado2D *M)
{
   cout<<"Nhap toa do (x, y): ";
   s>>M->x>>M->y;
   return s;
}
ostream &operator<<(ostream &s, Toado2D *M)
{
   cout<<"Toa do da nhap \n";
   s<<"("<<M->x<<","<<M->y<<")"<<endl;
   return s;
} 

int Toado2D::operator<=(Toado2D *M)
{
   if(this->x <= M->x && this->y <= M->y)
   return 1;
      else
      return 0;    
}
/*int Toado2D::operator=(Toado2D *M)
{
   if(this->x = M->x && this->y = M->y)
   return 1;
      else
      return 0; 
} */
int Toado2D::operator>(Toado2D *M)
{
   if(this->x > M->x && this->y > M->y)
   return 1;
      else
      return 0; 
}
main()
{
   first = NULL;
   last = NULL;
   NhapToaDo();  
}


If you need to get a modern compiler, here are some options:
This is the option I recommend, considering the formidable alternatives. I did not include options that I am certain are only for platforms other than Windows (XCode 4).

The list of good free IDEs includes but is not limited to:

1- Code::Blocks -> http://www.codeblocks.org/downloads
2- Visual Studio C++ Express -> http://www.microsoft.com/express/Downloads/#2010-Visual-CPP
3- Netbeans -> http://netbeans.org/downloads/
4- Eclipse (CDT) -> http://www.eclipse.org/cdt/downloads.php
5- QT Creator -> http://qt.nokia.com/downloads (scroll down a bit to download it as a standalone)

Eclipse has a little bit of a learning curve, just as a warning.


Make the change to wxDev-C++
This is the recommended option if you really like Dev-C++ or if a professor, boss, or team requires you to continue to use Dev-C++ or a derivative. wxDev-C++ is being updated, it's a bit more modern, it features a designer for wxWidgets should you want to create GUI applications, and finally as the name implies it is based on the original.

You can download wxDev-C++ here: http://wxdsgn.sourceforge.net/?q=node/4


from this thread:
http://www.cplusplus.com/articles/36vU7k9E/

EDIT: Line 38 is wrong. It's an assignment. Change it to if(first == NULL)

That way last is NULL too (the first time) and you have a crash on line 44
Last edited on
ok! thank for all comments..
Topic archived. No new replies allowed.