Advertisement
Josif_tepe

Untitled

Mar 20th, 2021
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. class Point{
  5. private:
  6.     double x, y;
  7. public:
  8.     Point() { // empty constructor
  9.     }
  10.     Point(double _x, double _y) { // parameter constructor
  11.         x = _x;
  12.         y = _y;
  13.     }
  14.     ~Point() {
  15.        
  16.     }
  17.     double get_x() const {
  18.         return x;
  19.     }
  20.     double get_y() const {
  21.         return y;
  22.     }
  23.     void input() {
  24.         cin >> x >> y;
  25.     }
  26.     void print() {
  27.         cout << x << " " << y << endl;
  28.     }
  29.     void set_x(double _x) {
  30.         x = _x;
  31.     }
  32.     void set_y(double _y) {
  33.         y = _y;
  34.     }
  35. };
  36. int main() {
  37.    
  38.     Point p;
  39.     p.set_x(10.0);
  40.     p.set_y(5.0);
  41.    
  42.     cout << p.get_x() << " " << p.get_y() << endl;
  43.    
  44.     return 0;
  45. }
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement