Advertisement
ArBa

winodws rejnewan

Jan 20th, 2018
416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.21 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h> //do wywalenia z printf'a,i
  3.  
  4. class Window {
  5.   private:
  6.     int x_up, y_up, x_down, y_down;
  7.     double factor;
  8.   public:
  9.      Window();
  10.     ~Window() {};  //destruktor
  11.     void resize(int);
  12.     void resize(double);
  13.     int return_value() {
  14.     return x_down - x_up;
  15.     };
  16. };
  17. Window operator +(Window A, Window B) { //przeciążenie operatora!
  18.     Window out;
  19.     out.resize(A.return_value() + B.return_value()-out.return_value());
  20.     return out;
  21. }
  22. Window::Window() {  //konstruktor
  23.     x_up = 0;
  24.     y_up = 0;
  25.     x_down = 200;
  26.     y_down = 200;
  27. }
  28. void Window::resize(int plus) { //zmiana okna
  29.     x_down += plus;
  30.     y_down += plus;
  31. }
  32. void Window::resize(double factor) {  //zmiana okna przeciążona
  33.     x_down = (x_down - x_up) * factor + x_up;
  34.     y_down = (y_down - y_up) * factor + y_up;
  35. }
  36. int main() {
  37.     Window *window_ptr = new Window[2];
  38.     (window_ptr)->resize(-100);
  39.     (window_ptr + 1)->resize(1.5);
  40.     printf("1: %d\t2: %d\n", window_ptr->return_value(),
  41.        (window_ptr + 1)->return_value());
  42.     *window_ptr = *window_ptr + *(window_ptr + 1);
  43.     printf("1+2: %d\n", window_ptr->return_value());
  44.     delete[]window_ptr;
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement