// Program to demonstrate the rectangular coordinate systems' Point. // Assignment-20 // rectpnt.cpp, Author - Krishna Kumar Khatri. // Uncomment ONLY the following line if you are using Turbo/Borland compiler. // #define TC #ifdef TC #include #else #include using namespace std; #endif #include // For getch. class Point { int x; int y; public: Point(const int& fp = 0, const int& sp = 0) : x(fp), y(sp) { } void add(const int&); void sub(const int&); //void angle(); void display(); }; void Point::add(const int& inc) { x += inc; y += inc; } void Point::sub(const int& dec) { x -= dec; y -= dec; } void Point::display() { cout << "x=" << x << ", y=" << y; } int main() { #ifdef TC clrscr(); #endif int a, b; int in = 3, de = 2; cout << "Enter co-ordinate points (x, y): "; cin >> a >> b; Point pt(a, b); cout << endl << "Original points, "; pt.display(); pt.add(in); cout << endl << endl << "Incremented by " << in; cout << endl << "Modified point is, "; pt.display(); pt.sub(de); cout << endl << endl << "Decremented by " << de; cout << endl << "Modified point is, "; pt.display(); cout << endl << endl << "Program over. Press any key to exit..."; getch(); return 0; // Successful termination. }