question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • macaiala
    New Member
    • Oct 2006
    • 1

    question

    how can I define a Point type in my program?
    I dont know how to use the class POINT.When I use a object point the compiler send me am error.It say that point identifier dont find.
    thanks
  • sanketbarot
    New Member
    • Sep 2006
    • 30

    #2
    What is Point?

    Comment

    • tyreld
      New Member
      • Sep 2006
      • 144

      #3
      C++ doesn't come with a built in Point class. So, you must define the class yourself. The following is one possible way you could go about it.

      Code:
      class Point {
      public:
         Point();
         ~Point(int a, int b);
      
         int getX();
         int getY();
         void setX();
         void setY();
      private:
         int x,y;
      }
      
      
      Point::Point(int a, int b)
      {
         x = a;
         y = b;
      }
      
      int Point::getX() { return x; }
      
      int Point::getY() { return y; }
      
      void Point::setX(int a) { x = a; }
      
      void Point::setY(int b) { x = b; }

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        C/C++ don't come with a standard point type but Windows does, it has a structure

        POINT

        or a class

        CPoint

        but you will need to have included Windows.h to get them (and be programming in a Windows environment of course).

        Comment

        Working...