Minggu, 24 April 2011

class point

#include <cstdlib>
#include <iostream>

using namespace std;
//create a class POINT
class TITIK {
      int X,Y;
      public :
//create function constructor for the class POINT
    TITIK (int XX, int YY){
    X=XX;
    Y=YY;
   }
//create function show XY
    void showXY(){
   cout<<"nilai X: "<<X<<endl;
   cout<<"nilai Y: "<<Y<<endl;
  }
//declaring that reverse the function object operator POINT
  TITIK TITIK ::operator +(TITIK P);
 };
//implementation of the above operator function
TITIK TITIK ::operator +(TITIK P){
return TITIK (P.X+X, P.Y+Y);
}

0 komentar:

Posting Komentar