Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- class Wektor
- {
- public:
- double x, y;
- Wektor()
- {
- this->x = 0;
- this->y = 0;
- }
- Wektor(double x, double y)
- {
- this->x = x;
- this->y = y;
- }
- void wprowadz_x()
- {
- cout << "Podaj x: ";
- cin >> x;
- }
- void wprowadz_y()
- {
- cout << "Podaj y: ";
- cin >> y;
- }
- void wypisz()
- {
- cout << x << " " << y << endl;
- }
- Wektor operator +(const Wektor &n)
- {
- return Wektor( this->x + n.x, this->y + n.y);
- }
- Wektor operator -(const Wektor &n)
- {
- return Wektor(this->x - n.x, this->y - n.y);
- }
- friend Wektor operator *(const Wektor &, const Wektor &);
- };
- Wektor operator *(const Wektor &n, const Wektor &m)
- {
- return Wektor(this->x * m.x, this->y * m.y);
- }
- int main()
- {
- Wektor w1(7,4);
- Wektor w2(2,2);
- Wektor w3 = w1 * w2;
- w3.wypisz();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement