Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Wektor {
- private:
- float x;
- float y;
- public:
- Wektor(float xx, float yy) {
- x = xx;
- y = yy;
- }
- Wektor() {
- x = 0;
- y = 0;
- }
- Wektor operator + (const Wektor& w) {
- Wektor nowy;
- nowy.x = x + w.x;
- nowy.y = y + w.y;
- return nowy;
- }
- bool operator != (const Wektor& w) {
- return (x != w.x || y != w.y);
- }
- bool operator == (const Wektor& w) {
- return (x == w.x && y == w.y);
- }
- void wypisz() {
- cout<<"x = "<<x<<" y = "<<y<<endl;
- }
- };
- int main()
- {
- Wektor w(4.0, 2.0);
- Wektor v(1.0, 1.5);
- Wektor y(4.0, 2.0);
- Wektor z = w + v;
- w.wypisz();
- v.wypisz();
- cout<<"---------------\n";
- z.wypisz();
- cout<<std::boolalpha<<(w != y)<<endl;
- cout<<std::boolalpha<<(w == y)<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement