Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- using namespace std;
- class Czlowiek
- {
- private:
- int szczescie;
- public:
- Czlowiek(){}
- Czlowiek(int szczescie)
- {
- this->szczescie=szczescie;
- }
- int getSzczescie()
- {
- return szczescie;
- }
- Czlowiek operator/(Czlowiek &cz);
- };
- Czlowiek Czlowiek::operator/(Czlowiek &cz)
- {
- Czlowiek kopia((this->szczescie)*(cz.getSzczescie()));
- return kopia;
- }
- ostream &operator<<(ostream& str, Czlowiek& cz)
- {
- str<<"Pomnozone szczescie: "<<cz.getSzczescie();
- return str;
- }
- int main()
- {
- int szczescie1,szczescie2;
- cout<<"Podaj szczescie pierwszej osoby: ";
- cin>>szczescie1;
- cout<<"Podaj szczescie drugiej osoby: ";
- cin>>szczescie2;
- Czlowiek cz1(szczescie1);
- Czlowiek cz2(szczescie2);
- Czlowiek cz3 = cz1/cz2;
- cout<<cz3<<endl;
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement