[help]Nạp chồng nhập, xuất tham số con trỏ!

giúp mình với! code này run được nhưng báo lỗi trong khi nhập x, y. Mình nghĩ lỗi ở đâu đó, nhưng mình ko sửa được…:stuck_out_tongue:

#include<iostream.h>
#include<conio.h>
#include<iomanip.h>

class Toado2D
{
      private:
         int x;
         int y;
         Toado2D *next;
      public:
         Toado2D()
         {
            x = 0;
            y = 0;
         }
         Toado2D(int x, int y)
         {
            this->x = x;
            this->y = y;
         }         
         Toado2D operator<=(Toado2D M);
         Toado2D operator=(Toado2D M);
         Toado2D operator>(Toado2D M);
         friend istream &operator>>(istream &s, Toado2D *M);
         friend ostream &operator<<(ostream &s, Toado2D *M);
};

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 
";
   s<<"("<<M.x<<","<<M.y<<")"<<endl;
   return s;
} */

main()
{
     Toado2D *A;
     cin>>A;
     getch();
}

[QUOTE=lytieulong_269;36799]giúp mình với! code này run được nhưng báo lỗi trong khi nhập x, y. Mình nghĩ lỗi ở đâu đó, nhưng mình ko sửa được…:stuck_out_tongue:

#include<iostream.h>
#include<conio.h>
#include<iomanip.h>

class Toado2D
{
      private:
         int x;
         int y;
         Toado2D *next;
      public:
         Toado2D()
         {
            x = 0;
            y = 0;
         }
         Toado2D(int x, int y)
         {
            this->x = x;
            this->y = y;
         }         
         Toado2D operator<=(Toado2D M);
         Toado2D operator=(Toado2D M);
         Toado2D operator>(Toado2D M);
         friend istream &operator>>(istream &s, Toado2D *M);
         friend ostream &operator<<(ostream &s, Toado2D *M);
};

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 
";
   s<<"("<<M.x<<","<<M.y<<")"<<endl;
   return s;
} */

main()
{
     Toado2D *A;
     cin>>A;
     getch();
}

[/QUOTE]

Toado2D *A;
cin>>A;

Con trỏ A chưa đc cấp phát bộ nhớ thì lỗi chứ sao.

trời! Ngớ ngẩn quá…
Cảm ơn pan nhiều nha!