Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h> //do wywalenia z printf'a,i
- class Window {
- private:
- int x_up, y_up, x_down, y_down;
- double factor;
- public:
- Window();
- ~Window() {}; //destruktor
- void resize(int);
- void resize(double);
- int return_value() {
- return x_down - x_up;
- };
- };
- Window operator +(Window A, Window B) { //przeciążenie operatora!
- Window out;
- out.resize(A.return_value() + B.return_value()-out.return_value());
- return out;
- }
- Window::Window() { //konstruktor
- x_up = 0;
- y_up = 0;
- x_down = 200;
- y_down = 200;
- }
- void Window::resize(int plus) { //zmiana okna
- x_down += plus;
- y_down += plus;
- }
- void Window::resize(double factor) { //zmiana okna przeciążona
- x_down = (x_down - x_up) * factor + x_up;
- y_down = (y_down - y_up) * factor + y_up;
- }
- int main() {
- Window *window_ptr = new Window[2];
- (window_ptr)->resize(-100);
- (window_ptr + 1)->resize(1.5);
- printf("1: %d\t2: %d\n", window_ptr->return_value(),
- (window_ptr + 1)->return_value());
- *window_ptr = *window_ptr + *(window_ptr + 1);
- printf("1+2: %d\n", window_ptr->return_value());
- delete[]window_ptr;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement