C++ Program To Find Negation Of A Number | C++ Programming

C++ Program To Find Negation Of A Number

#include<iostream>
using namespace std;
class point{
 int x,y;
 public:
  void getdata()
  {
   cout<<"Enter x and y coordinate:";
   cin>>x>>y;
  }
  void display()
  {
   cout<<"("<<x<<","<<y<<")";
  }
 point operator -()
 {
  point t;
  t.x=-x;
  t.y=-y;
  return t;
 }
};
int main()
{
 point p,q;
 p.getdata();
 q=-p;
 cout<<"q=";
 q.display();
}

OUTPUT


Enter x and y coordinate:
5
4
q=(-5,-4)

Post a Comment

0 Comments